From 6860d114fc481baf25cc66377ade432154c571a3 Mon Sep 17 00:00:00 2001 From: David Lee Date: Fri, 20 Dec 2013 00:30:52 -0800 Subject: [PATCH 01/84] Fix shortcuts offset when branch_shortcuts encounters detached HEAD (fixes #127) --- lib/git/branch_shortcuts.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/git/branch_shortcuts.sh b/lib/git/branch_shortcuts.sh index 1e933b9..9a7e94a 100644 --- a/lib/git/branch_shortcuts.sh +++ b/lib/git/branch_shortcuts.sh @@ -32,6 +32,7 @@ EOF # Set numbered file shortcut in variable local e=1 + IFS=$'\n' for branch in $($_git_cmd branch "$@" | sed "s/^[* ]\{2\}//"); do export $git_env_char$e="$branch" if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi From 413351a203c3260daf17c864501213bc3fff6668 Mon Sep 17 00:00:00 2001 From: Chas Ballew Date: Sun, 26 Jan 2014 01:50:56 -0500 Subject: [PATCH 02/84] Fix upcoming Git 2.0 breaking change to `git add -A`. --- lib/git/aliases.sh | 2 +- lib/git/status_shortcuts.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 91d95de..9156fe9 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -148,7 +148,7 @@ if [ "$git_setup_aliases" = "yes" ]; then _alias $git_commit_no_msg_alias='git commit -C HEAD' _alias $git_log_stat_alias='git log --stat --max-count=5' _alias $git_log_graph_alias='git log --graph --max-count=5' - _alias $git_add_all_alias='git add -A' + _alias $git_add_all_alias='git add --all .' fi diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index fb823b4..e5686c2 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -233,7 +233,7 @@ git_commit_all() { local appending=" | \033[0;36mappending '\033[1;36m$APPEND\033[0;36m' to commit message.\033[0m" fi echo -e "\033[0;33mCommitting all files (\033[0;31m$changes\033[0;33m)\033[0m$appending" - git_commit_prompt "git add -A" + git_commit_prompt "git add --all ." else echo "# No changed files to commit." fi From 65088ce7160e53efe1128f835a09c3d1bec8ab8e Mon Sep 17 00:00:00 2001 From: Test User Date: Tue, 8 Apr 2014 13:21:16 +0300 Subject: [PATCH 03/84] Ensure C locale is used when processing command output This change makes sure LC_MESSAGES is set to C whenever command output is run through grep, sed etc. Otherwise aliasing will fail whenever localized messages are printed. This should fix #98 and #64. --- lib/git/shell_shortcuts.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 9bdbe14..cca9de6 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -21,7 +21,7 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e # Do it in a function so we don't bleed variables function _git_wrap_commands() { # Define 'whence' for bash, to get the value of an alias - type whence > /dev/null 2>&1 || function whence() { type "$@" | sed -$SED_REGEX_ARG -e "s/.*is aliased to \`//" -e "s/'$//"; } + type whence > /dev/null 2>&1 || function whence() { LC_MESSAGES="C" type "$@" | sed -$SED_REGEX_ARG -e "s/.*is aliased to \`//" -e "s/'$//"; } local cmd='' for cmd in $(echo $scmb_wrapped_shell_commands); do if [ "${scmbDebug:-}" = "true" ]; then echo "SCMB: Wrapping $cmd..."; fi @@ -35,7 +35,7 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e fi fi - case "$(type $cmd 2>&1)" in + case "$(LC_MESSAGES="C" type $cmd 2>&1)" in # Don't do anything if command already aliased, or not found. *'exec_scmb_expand_args'*) @@ -52,7 +52,7 @@ if [ "$shell_command_wrapping_enabled" = "true" ] || [ "$bash_command_wrapping_e unalias $cmd # Detect original $cmd type, and escape - case "$(type $cmd 2>&1)" in + case "$(LC_MESSAGES="C" type $cmd 2>&1)" in # Escape shell builtins with 'builtin' *'is a shell builtin'*) local escaped_cmd="builtin $cmd";; # Get full path for files with 'find_binary' function @@ -189,4 +189,4 @@ EOF # Setup aliases alias ll="exec_scmb_expand_args ls_with_file_shortcuts" -alias la="ll -A" \ No newline at end of file +alias la="ll -A" From ee5c1e5aa0c124b0250555beb89e224d47122d8a Mon Sep 17 00:00:00 2001 From: aero-z Date: Thu, 12 Jun 2014 02:47:56 -0400 Subject: [PATCH 04/84] Changing the output for git status when there is a rename and modify at the same time --- lib/git/status_shortcuts.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/git/status_shortcuts.rb b/lib/git/status_shortcuts.rb index d5c8886..2b656db 100644 --- a/lib/git/status_shortcuts.rb +++ b/lib/git/status_shortcuts.rb @@ -127,7 +127,12 @@ end @stat_hash[group] << {:msg => msg, :col => col, :file => file} if msg # Work tree modification states - if y == "M" + if x == "R" && y == "M" + # Extract the second file name from the format x -> y + quoted, unquoted = /^(?:"(?:[^"\\]|\\.)*"|[^"].*) -> (?:"((?:[^"\\]|\\.)*)"|(.*[^"]))$/.match(file)[1..2] + renamed_file = quoted || unquoted + @stat_hash[:unstaged] << {:msg => " modified", :col => :mod, :file => renamed_file} + elsif x != "R" && y == "M" @stat_hash[:unstaged] << {:msg => " modified", :col => :mod, :file => file} elsif y == "D" && x != "D" && x != "U" # Don't show deleted 'y' during a merge conflict. From a1afeef0c41f93f594290b01da2950b32701a7bc Mon Sep 17 00:00:00 2001 From: keen99 Date: Tue, 8 Jul 2014 16:01:58 -0400 Subject: [PATCH 05/84] make _create_or_patch_scmbrc noclobber safe use >| instead of > to override noclobber on write (works for both bash and zsh) --- lib/scm_breeze.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scm_breeze.sh b/lib/scm_breeze.sh index 7d84148..59e4548 100644 --- a/lib/scm_breeze.sh +++ b/lib/scm_breeze.sh @@ -48,7 +48,7 @@ _create_or_patch_scmbrc() { # If file exists, attempt to update it with any new settings elif [ -n "$1" ]; then # Create diff of example file, substituting example file for user's config. - git diff $1 "$prefix""scmbrc.example" | sed "s/$prefix""scmbrc.example/.$prefix""scmbrc/g" > $patchfile + git diff $1 "$prefix""scmbrc.example" | sed "s/$prefix""scmbrc.example/.$prefix""scmbrc/g" >| $patchfile if [ -s $patchfile ]; then # If patchfile is not empty cd "$HOME" # If the patch cannot be applied cleanly, show the updates and tell user to update file manually. From ee450688fb7f38e908a6fe5f2ccdb270b3cf4ff1 Mon Sep 17 00:00:00 2001 From: keen99 Date: Tue, 8 Jul 2014 17:04:31 -0400 Subject: [PATCH 06/84] add a bit more detail around install.sh in readme install.sh is really required, you can't just clone source and go. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index ec4181c..fb635e7 100644 --- a/README.markdown +++ b/README.markdown @@ -287,7 +287,7 @@ git clone git://github.com/ndbroadbent/scm_breeze.git ~/.scm_breeze source ~/.bashrc # or source ~/.zshrc ``` -The install script just adds the following line to your `.bashrc` or `.zshrc`: +The install script creates required default configs and adds the following line to your `.bashrc` or `.zshrc`: `[ -s "$HOME/.scm_breeze/scm_breeze.sh" ] && source "$HOME/.scm_breeze/scm_breeze.sh"` From 1e9d60a06aa4bf4c36f56b3f613e0c4d4d5b9b47 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 2 Oct 2014 14:19:36 -0400 Subject: [PATCH 07/84] `gh` is the new `hub` `gh` is the new `hub`, rewritten to be fast and efficient. http://owenou.com/gh/ If has been adopted by GitHub themselves and will replace `hub` entirely, see: https://github.com/github/hub/issues/475 This patch simply checks for `gh` as a possible `_git_cmd` in addition to hub, restoring scm_breeze functionality for people who have switched to gh. --- lib/git/aliases.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 9156fe9..6003a48 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -20,7 +20,7 @@ unset -f git > /dev/null 2>&1 export _git_cmd="$(\which git)" # Wrap git with the 'hub' github wrapper, if installed (https://github.com/defunkt/hub) if type hub > /dev/null 2>&1; then export _git_cmd="hub"; fi - +if type gh > /dev/null 2>&1; then export _git_cmd="gh"; fi # Create 'git' function that calls hub if defined, and expands all numeric arguments function git(){ From 70c9501550b5e6707e64775ff3d9aa6bc3925455 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 2 Oct 2014 20:42:43 -0400 Subject: [PATCH 08/84] fix ability to undefine default aliases in zsh The ability to not define default aliases in the `.git.scmbrc` file leading to not having those aliases not present worked fine in bash. However, this seems to still have thrown an error in zsh. For example, if you commented out the line: git_checkout_alias="gco" then when sourcing scm_breeze aliases.sh would throw an error. This applied only to aliases defined with the `_alias()` function and not those with the `_git_alias()` function. To fix this, I wrapped `_alias()` in a similar check to the one `_git_alias()` has, where it passes the portions as arguments and verifies the first is present before proceeding. I'm not 100% certain why seperate functions exist for these two things to begin with (as far as I can tell from a cursory examination the main difference is `_git_aliases()` defines a tab completion?) but I believe my change has fixed the ability to comment out aliases in `.git.scmbrc` in zsh for users who do not want them (I'm in this boat, there are too many for me and I get confused). I tested manually in both bash and zsh and it appears to work, however you might want to review this before merging given my relative unfamiliarity with the codebase. --- lib/git/aliases.sh | 34 +++++++++++++++++----------------- lib/scm_breeze.sh | 8 +++++++- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 6003a48..eda83bf 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -37,7 +37,7 @@ function git(){ esac } -_alias $git_alias='git' +_alias "$git_alias" "git" # -------------------------------------------------------------------- @@ -75,14 +75,14 @@ __git_alias () { # -------------------------------------------------------------------- # SCM Breeze functions -_alias $git_status_shortcuts_alias="git_status_shortcuts" -_alias $git_add_shortcuts_alias="git_add_shortcuts" -_alias $exec_scmb_expand_args_alias="exec_scmb_expand_args" -_alias $git_show_files_alias="git_show_affected_files" -_alias $git_commit_all_alias='git_commit_all' +_alias "$git_status_shortcuts_alias" "git_status_shortcuts" +_alias "$git_add_shortcuts_alias" "git_add_shortcuts" +_alias "$exec_scmb_expand_args_alias" "exec_scmb_expand_args" +_alias "$git_show_files_alias" "git_show_affected_files" +_alias "$git_commit_all_alias" "git_commit_all" # Git Index alias -_alias $git_index_alias="git_index" +_alias "$git_index_alias" "git_index" # Only set up the following aliases if 'git_setup_aliases' is 'yes' if [ "$git_setup_aliases" = "yes" ]; then @@ -139,16 +139,17 @@ if [ "$git_setup_aliases" = "yes" ]; then # Compound/complex commands - _alias $git_fetch_all_alias="git fetch --all" - _alias $git_pull_then_push_alias="git pull && git push" - _alias $git_fetch_and_rebase_alias='git fetch && git rebase' - _alias $git_commit_amend_alias='git commit --amend' + _alias "$git_fetch_all_alias" "git fetch --all" + _alias "$git_pull_then_push_alias" "git pull && git push" + _alias "$git_fetch_and_rebase_alias" "git fetch && git rebase" + _alias "$git_commit_amend_alias" "git commit --amend" + # Add staged changes to latest commit without prompting for message - _alias $git_commit_amend_no_msg_alias='git commit --amend -C HEAD' - _alias $git_commit_no_msg_alias='git commit -C HEAD' - _alias $git_log_stat_alias='git log --stat --max-count=5' - _alias $git_log_graph_alias='git log --graph --max-count=5' - _alias $git_add_all_alias='git add --all .' + _alias "$git_commit_amend_no_msg_alias" "git commit --amend -C HEAD" + _alias "$git_commit_no_msg_alias" "git commit -C HEAD" + _alias "$git_log_stat_alias" "git log --stat --max-count=5" + _alias "$git_log_graph_alias" "git log --graph --max-count=5" + _alias "$git_add_all_alias" "git add --all ." fi @@ -168,4 +169,3 @@ if [ $shell = "bash" ]; then else compdef _git_index_tab_completion git_index $git_index_alias fi - diff --git a/lib/scm_breeze.sh b/lib/scm_breeze.sh index 59e4548..2c692bb 100644 --- a/lib/scm_breeze.sh +++ b/lib/scm_breeze.sh @@ -10,7 +10,13 @@ enable_nullglob() { if [ $shell = "zsh" ]; then setopt NULL_GLOB; else shopt disable_nullglob() { if [ $shell = "zsh" ]; then unsetopt NULL_GLOB; else shopt -u nullglob; fi; } # Alias wrapper that ignores errors if alias is not defined. -_alias(){ alias "$@" 2> /dev/null; } +_safe_alias(){ alias "$@" 2> /dev/null; } +_alias() { + if [ -n "$1" ]; then + local alias_str="$1"; local cmd="$2" + _safe_alias $alias_str="$cmd" + fi +} find_binary(){ if [ $shell = "zsh" ]; then From f14015fc3ec29457a2e53616f112f98e65f9cb1b Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 2 Oct 2014 21:01:58 -0400 Subject: [PATCH 09/84] aliases: consistent indentation and quotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this is unrelated to the previous commit and zero functionality but while I was changing things I wanted to clean up the indentation and use consistent single quotes versus double quotes in the functions calls for `_alias()` and `_git_alias()`. In my opinion this makes the file more readable, but if it bothers you let me know and I’ll be happy to remove it from the pull request. --- lib/git/aliases.sh | 115 +++++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index eda83bf..c0bbf3d 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -75,81 +75,82 @@ __git_alias () { # -------------------------------------------------------------------- # SCM Breeze functions -_alias "$git_status_shortcuts_alias" "git_status_shortcuts" -_alias "$git_add_shortcuts_alias" "git_add_shortcuts" -_alias "$exec_scmb_expand_args_alias" "exec_scmb_expand_args" -_alias "$git_show_files_alias" "git_show_affected_files" -_alias "$git_commit_all_alias" "git_commit_all" +_alias "$git_status_shortcuts_alias" 'git_status_shortcuts' +_alias "$git_add_shortcuts_alias" 'git_add_shortcuts' +_alias "$exec_scmb_expand_args_alias" 'exec_scmb_expand_args' +_alias "$git_show_files_alias" 'git_show_affected_files' +_alias "$git_commit_all_alias" 'git_commit_all' # Git Index alias -_alias "$git_index_alias" "git_index" +_alias "$git_index_alias" 'git_index' # Only set up the following aliases if 'git_setup_aliases' is 'yes' if [ "$git_setup_aliases" = "yes" ]; then # Commands that deal with paths - __git_alias "$git_checkout_alias" "git" "checkout" - __git_alias "$git_commit_alias" "git" "commit" - __git_alias "$git_commit_verbose_alias" "git" "commit" "--verbose" - __git_alias "$git_reset_alias" "git" "reset" "--" - __git_alias "$git_reset_hard_alias" "git" "reset" "--hard" - __git_alias "$git_rm_alias" "git" "rm" - __git_alias "$git_blame_alias" "git" "blame" - __git_alias "$git_diff_alias" "git" "diff" "--" - __git_alias "$git_diff_word_alias" "git" "diff" "--word-diff" - __git_alias "$git_diff_cached_alias" "git" "diff" "--cached --" - __git_alias "$git_add_patch_alias" "git" "add" "-p" - __git_alias "$git_add_updated_alias" "git" "add" "-u" - __git_alias "$git_difftool_alias" "git" "difftool" + __git_alias "$git_checkout_alias" 'git' 'checkout' + __git_alias "$git_commit_alias" 'git' 'commit' + __git_alias "$git_commit_verbose_alias" 'git' 'commit' '--verbose' + __git_alias "$git_reset_alias" 'git' 'reset' '--' + __git_alias "$git_reset_hard_alias" 'git' 'reset' '--hard' + __git_alias "$git_rm_alias" 'git' 'rm' + __git_alias "$git_blame_alias" 'git' 'blame' + __git_alias "$git_diff_alias" 'git' 'diff' '--' + __git_alias "$git_diff_word_alias" 'git' 'diff' '--word-diff' + __git_alias "$git_diff_cached_alias" 'git' 'diff' '--cached --' + __git_alias "$git_add_patch_alias" 'git' 'add' '-p' + __git_alias "$git_add_updated_alias" 'git' 'add' '-u' + __git_alias "$git_difftool_alias" 'git' 'difftool' + # Custom default format for git log git_log_command="log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" - __git_alias "$git_log_alias" "git" "$git_log_command" + __git_alias "$git_log_alias" 'git' "$git_log_command" # Same as the above, but displays all the branches and remotes - __git_alias "$git_log_all_alias" "git" "$git_log_command" "--branches" "--remotes" + __git_alias "$git_log_all_alias" 'git' "$git_log_command" '--branches' '--remotes' # Standard commands - __git_alias "$git_clone_alias" "git" 'clone' - __git_alias "$git_fetch_alias" "git" 'fetch' - __git_alias "$git_checkout_branch_alias" "git" 'checkout' "-b" - __git_alias "$git_pull_alias" "git" 'pull' - __git_alias "$git_push_alias" "git" 'push' - __git_alias "$git_push_force_alias" "git" 'push' '-f' - __git_alias "$git_status_original_alias" "git" 'status' # (Standard git status) - __git_alias "$git_status_short_alias" "git" 'status' '-s' - __git_alias "$git_clean_alias" "git" "clean" - __git_alias "$git_clean_force_alias" "git" "clean" "-fd" - __git_alias "$git_remote_alias" "git" 'remote' '-v' - __git_alias "$git_rebase_alias" "git" 'rebase' - __git_alias "$git_rebase_interactive_alias" "git" 'rebase' "-i" - __git_alias "$git_rebase_alias_continue" "git" 'rebase' "--continue" - __git_alias "$git_rebase_alias_abort" "git" 'rebase' "--abort" - __git_alias "$git_reset_last_commit" "git" "reset HEAD~" - __git_alias "$git_merge_alias" "git" 'merge' - __git_alias "$git_merge_no_fast_forward_alias" "git" "merge" "--no-ff" - __git_alias "$git_merge_only_fast_forward_alias" "git" "merge" "--ff" - __git_alias "$git_cherry_pick_alias" "git" 'cherry-pick' - __git_alias "$git_show_alias" "git" 'show' - __git_alias "$git_show_summary" "git" 'show' '--summary' - __git_alias "$git_stash_alias" "git" 'stash' - __git_alias "$git_stash_apply_alias" "git" 'stash' 'apply' - __git_alias "$git_stash_pop_alias" "git" 'stash' 'pop' - __git_alias "$git_stash_list_alias" "git" 'stash' 'list' - __git_alias "$git_tag_alias" "git" 'tag' + __git_alias "$git_clone_alias" 'git' 'clone' + __git_alias "$git_fetch_alias" 'git' 'fetch' + __git_alias "$git_checkout_branch_alias" 'git' 'checkout' '-b' + __git_alias "$git_pull_alias" 'git' 'pull' + __git_alias "$git_push_alias" 'git' 'push' + __git_alias "$git_push_force_alias" 'git' 'push' '-f' + __git_alias "$git_status_original_alias" 'git' 'status' # (Standard git status) + __git_alias "$git_status_short_alias" 'git' 'status' '-s' + __git_alias "$git_clean_alias" 'git' 'clean' + __git_alias "$git_clean_force_alias" 'git' 'clean' '-fd' + __git_alias "$git_remote_alias" 'git' 'remote' '-v' + __git_alias "$git_rebase_alias" 'git' 'rebase' + __git_alias "$git_rebase_interactive_alias" 'git' 'rebase' '-i' + __git_alias "$git_rebase_alias_continue" 'git' 'rebase' '--continue' + __git_alias "$git_rebase_alias_abort" 'git' 'rebase' '--abort' + __git_alias "$git_reset_last_commit" 'git' 'reset HEAD~' + __git_alias "$git_merge_alias" 'git' 'merge' + __git_alias "$git_merge_no_fast_forward_alias" 'git' 'merge' '--no-ff' + __git_alias "$git_merge_only_fast_forward_alias" 'git' 'merge' '--ff' + __git_alias "$git_cherry_pick_alias" 'git' 'cherry-pick' + __git_alias "$git_show_alias" 'git' 'show' + __git_alias "$git_show_summary" 'git' 'show' '--summary' + __git_alias "$git_stash_alias" 'git' 'stash' + __git_alias "$git_stash_apply_alias" 'git' 'stash' 'apply' + __git_alias "$git_stash_pop_alias" 'git' 'stash' 'pop' + __git_alias "$git_stash_list_alias" 'git' 'stash' 'list' + __git_alias "$git_tag_alias" 'git' 'tag' # Compound/complex commands - _alias "$git_fetch_all_alias" "git fetch --all" - _alias "$git_pull_then_push_alias" "git pull && git push" - _alias "$git_fetch_and_rebase_alias" "git fetch && git rebase" - _alias "$git_commit_amend_alias" "git commit --amend" + _alias "$git_fetch_all_alias" 'git fetch --all' + _alias "$git_pull_then_push_alias" 'git pull && git push' + _alias "$git_fetch_and_rebase_alias" 'git fetch && git rebase' + _alias "$git_commit_amend_alias" 'git commit --amend' # Add staged changes to latest commit without prompting for message - _alias "$git_commit_amend_no_msg_alias" "git commit --amend -C HEAD" - _alias "$git_commit_no_msg_alias" "git commit -C HEAD" - _alias "$git_log_stat_alias" "git log --stat --max-count=5" - _alias "$git_log_graph_alias" "git log --graph --max-count=5" - _alias "$git_add_all_alias" "git add --all ." + _alias "$git_commit_amend_no_msg_alias" 'git commit --amend -C HEAD' + _alias "$git_commit_no_msg_alias" 'git commit -C HEAD' + _alias "$git_log_stat_alias" 'git log --stat --max-count=5' + _alias "$git_log_graph_alias" 'git log --graph --max-count=5' + _alias "$git_add_all_alias" 'git add --all .' fi From ed2240e21464222be7a0afc4c9635e8187c667d9 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Wed, 15 Oct 2014 02:21:35 -0400 Subject: [PATCH 10/84] BUGFIX: actually clear variables The current `git_clear_vars()` method appears to have iterated over all the existing set variable correctly, but never actually bothered to clear them. --- lib/git/status_shortcuts.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index e5686c2..41671d4 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -166,7 +166,12 @@ git_clear_vars() { local i for (( i=1; i<=$gs_max_changes; i++ )); do # Stop clearing after first empty var - if [[ -z "$(eval echo "\${$git_env_char$i:-}")" ]]; then break; fi + local env_var_i=${git_env_char}${i} + if [[ -z "$(eval echo "\${$env_var_i:-}")" ]]; then + break + else + unset $env_var_i + fi done } From 23e99709daf5c35b755841dd6457913c26839739 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Wed, 15 Oct 2014 02:41:21 -0400 Subject: [PATCH 11/84] integrate branch parsing into single system call The `git status --porcelain` command can take an additional argument `-b` which causes the porcelain output to also contain branch information in a stable and supposedly nonchanging way. This change adds that argument to the initial `git status` call, and parses the branch/ahead/behind information from that. The end result is the entire call to `git branch -v` can be removed, resulting in one less subshell command and hopefully a more reliable target across future versions of git. --- lib/git/status_shortcuts.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/git/status_shortcuts.rb b/lib/git/status_shortcuts.rb index 2b656db..e121b8b 100644 --- a/lib/git/status_shortcuts.rb +++ b/lib/git/status_shortcuts.rb @@ -22,14 +22,15 @@ @project_root = File.exist?(".git") ? Dir.pwd : `\git rev-parse --show-toplevel 2> /dev/null`.strip -@git_status = `\git status --porcelain 2> /dev/null` +@git_status = `\git status --porcelain -b 2> /dev/null` -git_branch = `\git branch -v 2> /dev/null` -@branch = git_branch[/^\* (\(no branch\)|[^ ]*)/, 1] -@ahead = git_branch[/^\* [^ ]* *[^ ]* *\[ahead ?(\d+).*\]/, 1] -@behind = git_branch[/^\* [^ ]* *[^ ]* *\[.*behind ?(\d+)\]/, 1] +git_status_lines = @git_status.split("\n") +git_branch = git_status_lines[0] +@branch = git_branch[/^## (?:Initial commit on )?([^ \.]+)/, 1] +@ahead = git_branch[/\[ahead ?(\d+).*\]/, 1] +@behind = git_branch[/\[.*behind ?(\d+)\]/, 1] -@changes = @git_status.split("\n") +@changes = git_status_lines[1..-1] # Exit if too many changes exit if @changes.size > ENV["gs_max_changes"].to_i @@ -131,7 +132,7 @@ end # Extract the second file name from the format x -> y quoted, unquoted = /^(?:"(?:[^"\\]|\\.)*"|[^"].*) -> (?:"((?:[^"\\]|\\.)*)"|(.*[^"]))$/.match(file)[1..2] renamed_file = quoted || unquoted - @stat_hash[:unstaged] << {:msg => " modified", :col => :mod, :file => renamed_file} + @stat_hash[:unstaged] << {:msg => " modified", :col => :mod, :file => renamed_file} elsif x != "R" && y == "M" @stat_hash[:unstaged] << {:msg => " modified", :col => :mod, :file => file} elsif y == "D" && x != "D" && x != "U" From 802f4987c36730d6b9496c7a96374bfee5b1695e Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Wed, 15 Oct 2014 12:57:28 -0400 Subject: [PATCH 12/84] set up multi-os testing in travis Requires beta access, thankfully the travis gods have blessed us for the main repo and my fork! This should allow us to make sure scm_breeze operates reliably in both Linux and BSD/Darwin, because there are small shell differences (especially with default tools) that are causing errors I noticed on MacOSX. --- .travis.yml | 12 +++++++++--- test/support/travisci_deps.sh | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100755 test/support/travisci_deps.sh diff --git a/.travis.yml b/.travis.yml index 3d40388..30f5fa2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,9 @@ -script: ./run_tests.sh -before_script: - - sudo apt-get install zsh +os: + - linux + - osx + +install: + - ./test/support/travisci_deps.sh + +script: + - ./run_tests.sh diff --git a/test/support/travisci_deps.sh b/test/support/travisci_deps.sh new file mode 100755 index 0000000..d4523ee --- /dev/null +++ b/test/support/travisci_deps.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Installs dependencies for travis-ci environments. + +# Install dependencies, which looks to be just bash & zsh. +# +# Darwin has zsh preinstalled already, so only need to install on Ubuntu. +# +# Note: $TRAVIS_OS_NAME will only be set on text boxes with multi-os enabled, +# so use negation test so it will fail gracefully on normal Travis linux setup. +# +# TODO: also perhaps later only on ZSH test box if we split those +if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then + sudo apt-get install zsh +fi From b6fd7ae829e2060a251fbe5cd06c7ab759f92e75 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Wed, 15 Oct 2014 14:12:24 -0400 Subject: [PATCH 13/84] split tests up by shell for concurrency More parallelism = faster tests. Also better isolation for changes that might only break on zsh or bash respectively. This is defined via env variable, so someone running locally will have all tests run sequentially as before. --- .travis.yml | 6 ++++++ run_tests.sh | 11 +++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30f5fa2..7abf0e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,12 @@ os: - linux - osx +env: + - TEST_SHELLS="zsh bash" + - TEST_SHELLS=bash + - TEST_SHELLS=zsh + - HI=mom + install: - ./test/support/travisci_deps.sh diff --git a/run_tests.sh b/run_tests.sh index fff4438..877f9ed 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -3,8 +3,15 @@ failed=false +# allow list of shells to run tests in to be overriden by environment variable +# if empty or null, use defaults +if [ -z "$TEST_SHELLS" ]; then + TEST_SHELLS="bash zsh" +fi + +echo "== Will run all tests with following shells: ${TEST_SHELLS}" for test in $(find test/lib -name *_test.sh); do - for shell in bash zsh; do + for shell in $TEST_SHELLS; do echo "== Running tests with [$shell]: $test" $shell $test || failed=true done @@ -16,4 +23,4 @@ if [ "$failed" = "true" ]; then else echo "All tests passed!" return 0; -fi \ No newline at end of file +fi From e7c56c7647ea491da3ecd13c80456c6f8b11d76a Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Wed, 15 Oct 2014 16:36:43 -0400 Subject: [PATCH 14/84] only install zsh on boxes that need it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit don’t bother on macosx (preinstalled) or if the test matrix for that box isn’t going to be testing in zsh. this should speed up test runs for most cases, and later we can define fast_failure and not have to wait for the longer ones. --- test/support/travisci_deps.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/test/support/travisci_deps.sh b/test/support/travisci_deps.sh index d4523ee..83cc32e 100755 --- a/test/support/travisci_deps.sh +++ b/test/support/travisci_deps.sh @@ -7,8 +7,26 @@ # # Note: $TRAVIS_OS_NAME will only be set on text boxes with multi-os enabled, # so use negation test so it will fail gracefully on normal Travis linux setup. -# -# TODO: also perhaps later only on ZSH test box if we split those if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then - sudo apt-get install zsh + + # okay, so we know we're probably on a linux box (or at least not an osx box) + # at this point. do we need to install zsh? let's say the default case is no: + needs_zsh=false + + # check if zsh is listed in the TEST_SHELLS environment variable, set by + # our travis-ci build matrix. + if [[ $TEST_SHELLS =~ zsh ]]; then needs_zsh=true; fi + + # if there is NO $TEST_SHELLS env variable persent (which should never happen, + # but maybe someone has been monkeying with the .travis.yml), run_tests.sh is + # going to fall back onto the default of testing everything, so we need zsh. + if [[ -z "$TEST_SHELLS" ]]; then needs_zsh=true; fi + + # finally, we install zsh if needed! + if $needs_zsh ; then + sudo apt-get install zsh + else + echo "No deps required." + fi + fi From f056d28b2eb1f20793119a5c48f75bef7f9954d7 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 16 Oct 2014 11:39:08 -0400 Subject: [PATCH 15/84] remove redundant test envs they were just there when we were making sure the env variable shell selection was working properly in all cases, now that we know it is, they can be removed. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7abf0e3..f2597de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,8 @@ os: - osx env: - - TEST_SHELLS="zsh bash" - TEST_SHELLS=bash - TEST_SHELLS=zsh - - HI=mom install: - ./test/support/travisci_deps.sh From b395596496373aeb90bbdd9fb3fddcfa7c01cb48 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 16 Oct 2014 12:19:11 -0400 Subject: [PATCH 16/84] dont use grep -P for cross-platform compatibility `grep -P` gives access to the PCRE matching engine, which is nice, however, the version of grep shipped on many BSD systems (including Darwin) does not have this flag. Currently, `grep -P` was being used in the `_includes()` test helper. For cross platform compatibility in tests, do not rely upon this option. Luckily, all existing tests seem to work fine without it already! --- test/lib/git/shell_shortcuts_test.sh | 2 +- test/support/test_helper.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 3a6843a..834f03b 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -82,7 +82,7 @@ test_ls_with_file_shortcuts() { ls_with_file_shortcuts > $temp_file ls_output=$(<$temp_file strip_colors) - # Compare as fixed strings (F), instead of regex (P) + # Compare as fixed strings (F), instead of normal grep behavior assertIncludes "$ls_output" '[1] a "b"' F assertIncludes "$ls_output" "[2] a 'b'" F assertIncludes "$ls_output" '[3] a [b]' F diff --git a/test/support/test_helper.sh b/test/support/test_helper.sh index 7407b59..cf211a6 100644 --- a/test/support/test_helper.sh +++ b/test/support/test_helper.sh @@ -34,7 +34,7 @@ verboseGitCommands() { #----------------------------------------------------------------------------- _includes() { - if [ -n "$3" ]; then regex="$3"; else regex=P; fi + if [ -n "$3" ]; then regex="$3"; else regex=''; fi if echo "$1" | grep -q$regex "$2"; then echo 0; else echo 1; fi } @@ -46,4 +46,3 @@ assertIncludes() { assertNotIncludes() { assertFalse "'$1' should not have contained '$2'" $(_includes "$@") } - From b2d86a16b2a0a53c8c0c176909fbdc0ec22ee732 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 16 Oct 2014 15:31:12 -0400 Subject: [PATCH 17/84] use perl instead of sed -r to strip colors in test `sed -r` is not present on some BSD based systems, including MacOSX Darwin. perl is standard pretty much everywhere, so this a more reliable way to test. Since this is only used for tests, any performance differences should not matter significantly. --- test/support/test_helper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/support/test_helper.sh b/test/support/test_helper.sh index cf211a6..ba9e472 100644 --- a/test/support/test_helper.sh +++ b/test/support/test_helper.sh @@ -15,7 +15,7 @@ fi # Strip color codes from a string strip_colors() { - sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" + perl -pe 's/\e\[[\d;]*m//g' } # Print space separated tab completion options From 1cd162434fb72c9050602703a76677707346a649 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 16 Oct 2014 16:10:52 -0400 Subject: [PATCH 18/84] Make sure we have physical path back from mktemp Darwin actually symlinks /var inside /private, but mktemp reports back the logical pathat time of file creation. So make sure we always get the full physical path to be absolutely certain when doing comparisons later, because thats how the Ruby status_shortcuts.rb script is going to obtain them. --- test/lib/git/shell_shortcuts_test.sh | 8 ++++++++ test/lib/git/status_shortcuts_test.sh | 1 + 2 files changed, 9 insertions(+) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 834f03b..2ace560 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -71,7 +71,15 @@ test_ls_with_file_shortcuts() { export git_env_char="e" TEST_DIR=$(mktemp -d -t scm_breeze.XXXXXXXXXX) + + # Darwin actually symlinks /var inside /private, but mktemp reports back the + # logical pathat time of file creation. So make sure we always get the + # full physical path to be absolutely certain when doing comparisons later, + # because thats how the Ruby status_shortcuts.rb script is going to obtain + # them. cd $TEST_DIR + TEST_DIR=`pwd -P` + touch 'test file' 'test_file' mkdir -p "a [b]" 'a "b"' "a 'b'" touch "a \"b\"/c" diff --git a/test/lib/git/status_shortcuts_test.sh b/test/lib/git/status_shortcuts_test.sh index aa86d2e..818183f 100755 --- a/test/lib/git/status_shortcuts_test.sh +++ b/test/lib/git/status_shortcuts_test.sh @@ -29,6 +29,7 @@ oneTimeSetUp() { export ga_auto_remove="yes" testRepo=$(mktemp -d -t scm_breeze.XXXXXXXXXX) + testRepo=`cd $testRepo && pwd -P` } oneTimeTearDown() { From ae4b93f52f0d3fc17cbe178aaf0683b3b397926d Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 16 Oct 2014 16:38:09 -0400 Subject: [PATCH 19/84] declare original location of cmds The previous tests assumed default locations for all commands, however they do not exist in the same place on all *nixes. I encountered this when the test was failing on MacOSX where it was expected hardcoded `/bin/sed` when in fact the code was identifying the correct local expansion of `/usr/bin/sed`. To make this test more robust, it now checks for the original location of all cmds and uses that in its expansion tests for `test_shell_command_wrapping()`. --- test/lib/git/shell_shortcuts_test.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 2ace560..1f8954f 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -31,6 +31,14 @@ oneTimeSetUp() { # Test functions function ln() { ln $@; } + + # Before aliasing, get original locations so we can compare them in the test + unalias mv rm sed cat 2>/dev/null + orig_mv=`which mv` + orig_rm=`which rm` + orig_sed=`which sed` + orig_cat=`which cat` + # Test aliases alias mv="nocorrect mv" alias rm="rm --option" @@ -58,11 +66,11 @@ assertAliasEquals(){ #----------------------------------------------------------------------------- test_shell_command_wrapping() { - assertAliasEquals "exec_scmb_expand_args /bin/rm --option" "rm" - assertAliasEquals "exec_scmb_expand_args nocorrect /bin/mv" "mv" - assertAliasEquals "exec_scmb_expand_args /bin/sed" "sed" - assertAliasEquals "exec_scmb_expand_args /bin/cat" "cat" - assertAliasEquals "exec_scmb_expand_args builtin cd" "cd" + assertAliasEquals "exec_scmb_expand_args $orig_rm --option" "rm" + assertAliasEquals "exec_scmb_expand_args nocorrect $orig_mv" "mv" + assertAliasEquals "exec_scmb_expand_args $orig_sed" "sed" + assertAliasEquals "exec_scmb_expand_args $orig_cat" "cat" + assertAliasEquals "exec_scmb_expand_args builtin cd" "cd" assertIncludes "$(declare -f ln)" "ln ()" assertIncludes "$(declare -f ln)" "exec_scmb_expand_args __original_ln" } From c234916b2bdb2d54b4ff7dc7c77e44029ee07c1e Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 16 Oct 2014 17:08:29 -0400 Subject: [PATCH 20/84] scripts should exit rather than return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit some shells are pickier about this. darwin uses a newer version of sh that complains about it. this is the ‘proper’ behavior in either scenario. --- run_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 877f9ed..2d5c061 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -19,8 +19,8 @@ done if [ "$failed" = "true" ]; then echo "Tests failed!" - return 1; + exit 1; else echo "All tests passed!" - return 0; + exit 0; fi From 9a9b6104e2e87a19854ac42418773a6dd51e0916 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Thu, 16 Oct 2014 17:20:49 -0400 Subject: [PATCH 21/84] Compatibility fix for Design Assets Management design.sh uses `readlink -m` to determine canonical path of git dir, which is not available on all *nix systems (including Darwin). Instead, use `pwd -P` to get canonical directory path in a more cross-platform compatible way. This is a change to an actual script rather than just a test, and it should make the Design Assets Management functionality of scm_breeze now function properly on MacOSX. --- lib/design.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/design.sh b/lib/design.sh index 5106247..d7e041a 100644 --- a/lib/design.sh +++ b/lib/design.sh @@ -23,7 +23,7 @@ # Add ignore rule to .git/info/exclude if not already present _design_add_git_exclude(){ - local git_dir="$(cd $1 && readlink -m $(git rev-parse --git-dir))" + local git_dir="$(cd $1 && cd `git rev-parse --git-dir` && pwd -P)" if [ -e "$git_dir/info/exclude" ] && ! $(grep -q "$project_design_dir" "$git_dir/info/exclude"); then echo "$project_design_dir" >> "$git_dir/info/exclude" fi From c6b9c398c89295bb97faebba4e2180fcf0ee31b3 Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Mon, 20 Oct 2014 15:16:04 -0400 Subject: [PATCH 22/84] temp before_script to debug sort order on travis I tested manually on OSX and linux, but lets make sure the same thing is true on travis-ci builds. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index f2597de..d038f60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,5 +9,8 @@ env: install: - ./test/support/travisci_deps.sh +before_script: + - echo -e "test_repo_11\ntest_repo_1" | sort + script: - ./run_tests.sh From fef74e26a5a4631f1eaaf1ecc4404de1b4cafbab Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 17 Dec 2014 10:52:48 +0600 Subject: [PATCH 23/84] Added alias for git pull-request (hub) --- git.scmbrc.example | 2 ++ lib/git/aliases.sh | 3 +++ 2 files changed, 5 insertions(+) diff --git a/git.scmbrc.example b/git.scmbrc.example index f7867a6..487c0fb 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -95,6 +95,8 @@ git_stash_apply_alias="gasha" git_stash_pop_alias="gashp" git_stash_list_alias="gashl" git_tag_alias="gt" +# Hub aliases (https://github.com/github/hub) +git_pull_request_alias="gpr" # Git Keyboard Shortcuts diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index c0bbf3d..e2d0d1a 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -151,6 +151,9 @@ if [ "$git_setup_aliases" = "yes" ]; then _alias "$git_log_stat_alias" 'git log --stat --max-count=5' _alias "$git_log_graph_alias" 'git log --graph --max-count=5' _alias "$git_add_all_alias" 'git add --all .' + + # Hub aliases (https://github.com/github/hub) + _alias "$git_pull_request_alias" 'git pull-request' fi From 2194bb1fae7d67daf26fd86213faf4decc962378 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 17 Dec 2014 10:55:35 +0600 Subject: [PATCH 24/84] gcob => gcb (alias for git checkout -b) --- git.scmbrc.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.scmbrc.example b/git.scmbrc.example index 487c0fb..c38be04 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -40,7 +40,7 @@ git_show_files_alias="gsf" exec_scmb_expand_args_alias="ge" # 2. Commands that handle paths (with shortcut args expanded) git_checkout_alias="gco" -git_checkout_branch_alias="gcob" +git_checkout_branch_alias="gcb" git_commit_alias="gc" git_commit_verbose_alias="gcv" git_reset_alias="grs" From 5ea1e69405bccf1a74cfec115938f2e27d036ac2 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 27 Dec 2014 21:31:10 +0600 Subject: [PATCH 25/84] Added example gif --- README.markdown | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index fb635e7..e79f2e8 100644 --- a/README.markdown +++ b/README.markdown @@ -6,7 +6,13 @@ a repository index with tab completion, and many other useful features.
-## Demo video +## Demos + +Adding a range of files, and pressing `Ctrl+X, C` to commit: + +
+ +
From 84b765eab9d645a1c9185b6ed311e5bf821212ba Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Tue, 20 Jan 2015 22:21:39 -0500 Subject: [PATCH 26/84] Fix argument expansion in __git_alias --- lib/git/aliases.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index e2d0d1a..c7f8fc6 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -64,11 +64,11 @@ _git # Usage: __git_alias __git_alias () { if [ -n "$1" ]; then - local alias_str="$1"; local cmd_prefix="$2"; local cmd="$3"; local cmd_args="${4-}" - alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }$cmd_args" + local alias_str="$1"; local cmd_prefix="$2"; local cmd="$3"; local cmd_args=("${@:4}") + alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }${cmd_args[*]}" if [ "$shell" = "bash" ]; then - __define_git_completion $alias_str $cmd - complete -o default -o nospace -F _git_"$alias_str"_shortcut $alias_str + __define_git_completion "$alias_str" "$cmd" + complete -o default -o nospace -F _git_"$alias_str"_shortcut "$alias_str" fi fi } From 349896b0cfe6eee8ac74d72ee6b54f12c158b6fb Mon Sep 17 00:00:00 2001 From: Jean Blanchard Date: Fri, 6 Mar 2015 09:38:15 +0000 Subject: [PATCH 27/84] Make ls aliases optional --- git.scmbrc.example | 2 + lib/git/shell_shortcuts.sh | 124 ++++++++++++++------------- test/lib/git/shell_shortcuts_test.sh | 1 + 3 files changed, 66 insertions(+), 61 deletions(-) diff --git a/git.scmbrc.example b/git.scmbrc.example index c38be04..e6566de 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -114,3 +114,5 @@ git_commit_all_with_ci_skip_keys="\C-xv" # CTRL+x, v (Appends [ci skip] to c shell_command_wrapping_enabled="true" # Here you can tweak the list of wrapped commands. scmb_wrapped_shell_commands="vim emacs gedit cat rm cp mv ln cd" +# Add numbered shortcuts to output of ls -l, just like 'git status' +shell_ls_aliases_enabled="true" diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index cca9de6..2388290 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -108,50 +108,51 @@ fi # Function wrapper around 'll' # Adds numbered shortcuts to output of ls -l, just like 'git status' -unalias ll > /dev/null 2>&1; unset -f ll > /dev/null 2>&1 -function ls_with_file_shortcuts { - local ll_output - if [ "$_ls_bsd" != "BSD" ]; then - ll_output="$(\ls -lhv --group-directories-first --color "$@")" - else - ll_output="$(CLICOLOR_FORCE=1 \ls -l -G "$@")" - fi +if [ "$shell_ls_aliases_enabled" = "true" ]; then + unalias ll > /dev/null 2>&1; unset -f ll > /dev/null 2>&1 + function ls_with_file_shortcuts { + local ll_output + if [ "$_ls_bsd" != "BSD" ]; then + ll_output="$(\ls -lhv --group-directories-first --color "$@")" + else + ll_output="$(CLICOLOR_FORCE=1 \ls -l -G "$@")" + fi - if [[ $shell == "zsh" ]]; then - # Ensure sh_word_split is on - if setopt | grep -q shwordsplit; then SHWORDSPLIT_ON=true; fi - setopt shwordsplit - fi + if [[ $shell == "zsh" ]]; then + # Ensure sh_word_split is on + if setopt | grep -q shwordsplit; then SHWORDSPLIT_ON=true; fi + setopt shwordsplit + fi - # Parse path from args - OLDIFS="$IFS"; IFS=$'\n' - for arg in $@; do - if [ -d "$arg" ]; then local rel_path="${arg%/}"; fi - done - IFS="$OLDIFS" + # Parse path from args + OLDIFS="$IFS"; IFS=$'\n' + for arg in $@; do + if [ -d "$arg" ]; then local rel_path="${arg%/}"; fi + done + IFS="$OLDIFS" - # Replace user/group with user symbol, if defined at ~/.user_sym - # Before : -rw-rw-r-- 1 ndbroadbent ndbroadbent 1.1K Sep 19 21:39 scm_breeze.sh - # After : -rw-rw-r-- 1 𝐍 𝐍 1.1K Sep 19 21:39 scm_breeze.sh - if [ -e $HOME/.user_sym ]; then - # Little bit of ruby golf to rejustify the user/group/size columns after replacement - function rejustify_ls_columns(){ - ruby -e "o=STDIN.read;re=/^(([^ ]* +){2})(([^ ]* +){3})/;\ - u,g,s=o.lines.map{|l|l[re,3]}.compact.map(&:split).transpose.map{|a|a.map(&:size).max+1};\ - puts o.lines.map{|l|l.sub(re){|m|\"%s%-#{u}s %-#{g}s%#{s}s \"%[\$1,*\$3.split]}}" - } + # Replace user/group with user symbol, if defined at ~/.user_sym + # Before : -rw-rw-r-- 1 ndbroadbent ndbroadbent 1.1K Sep 19 21:39 scm_breeze.sh + # After : -rw-rw-r-- 1 𝐍 𝐍 1.1K Sep 19 21:39 scm_breeze.sh + if [ -e $HOME/.user_sym ]; then + # Little bit of ruby golf to rejustify the user/group/size columns after replacement + function rejustify_ls_columns(){ + ruby -e "o=STDIN.read;re=/^(([^ ]* +){2})(([^ ]* +){3})/;\ + u,g,s=o.lines.map{|l|l[re,3]}.compact.map(&:split).transpose.map{|a|a.map(&:size).max+1};\ + puts o.lines.map{|l|l.sub(re){|m|\"%s%-#{u}s %-#{g}s%#{s}s \"%[\$1,*\$3.split]}}" + } - ll_output=$(echo "$ll_output" | \sed -$SED_REGEX_ARG "s/ $USER/ $(/bin/cat $HOME/.user_sym)/g" | rejustify_ls_columns) - fi + ll_output=$(echo "$ll_output" | \sed -$SED_REGEX_ARG "s/ $USER/ $(/bin/cat $HOME/.user_sym)/g" | rejustify_ls_columns) + fi - if [ "$(echo "$ll_output" | wc -l)" -gt "50" ]; then - echo -e "\033[33mToo many files to create shortcuts. Running plain ll command...\033[0m" - echo "$ll_output" - return 1 - fi + if [ "$(echo "$ll_output" | wc -l)" -gt "50" ]; then + echo -e "\033[33mToo many files to create shortcuts. Running plain ll command...\033[0m" + echo "$ll_output" + return 1 + fi - # Use ruby to inject numbers into ls output - echo "$ll_output" | ruby -e "$( \cat < $file"; fi - let e++ - done - IFS="$OLDIFS" + OLDIFS="$IFS"; IFS=$'\n' + for file in $ll_files; do + if [ -n "$rel_path" ]; then file="$rel_path/$file"; fi + export $git_env_char$e="$(eval $_abs_path_command \"${file//\"/\\\"}\")" + if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi + let e++ + done + IFS="$OLDIFS" - # Turn off shwordsplit unless it was on previously - if [[ $shell == "zsh" ]] && [ -z "$SHWORDSPLIT_ON" ]; then unsetopt shwordsplit; fi -} + # Turn off shwordsplit unless it was on previously + if [[ $shell == "zsh" ]] && [ -z "$SHWORDSPLIT_ON" ]; then unsetopt shwordsplit; fi + } -# Setup aliases -alias ll="exec_scmb_expand_args ls_with_file_shortcuts" -alias la="ll -A" + # Setup aliases + alias ll="exec_scmb_expand_args ls_with_file_shortcuts" + alias la="ll -A" +fi diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 3a6843a..b826a0b 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -26,6 +26,7 @@ source "$scmbDir/lib/scm_breeze.sh" oneTimeSetUp() { export shell_command_wrapping_enabled="true" export scmb_wrapped_shell_commands="not_found cat rm cp mv ln cd sed" + export shell_ls_aliases_enabled="true" alias rvm="test" # Ensure tests run if RVM isn't loaded but $HOME/.rvm is present From d763faa68c8580dd049379e43e6e9c7ec32ad47f Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Thu, 30 Oct 2014 17:22:17 -0400 Subject: [PATCH 28/84] Add aliases for submodule update --- git.scmbrc.example | 2 ++ lib/git/aliases.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/git.scmbrc.example b/git.scmbrc.example index e6566de..3c9305f 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -95,6 +95,8 @@ git_stash_apply_alias="gasha" git_stash_pop_alias="gashp" git_stash_list_alias="gashl" git_tag_alias="gt" +git_submodule_update_alias="gsu" +git_submodule_update_rec_alias="gsur" # Hub aliases (https://github.com/github/hub) git_pull_request_alias="gpr" diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index c7f8fc6..ea626c6 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -137,6 +137,8 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_stash_pop_alias" 'git' 'stash' 'pop' __git_alias "$git_stash_list_alias" 'git' 'stash' 'list' __git_alias "$git_tag_alias" 'git' 'tag' + __git_alias "$git_submodule_update_alias" 'git' 'submodule' 'update' '--init' + __git_alias "$git_submodule_update_rec_alias" 'git' 'submodule' 'update' '--init' '--recursive' # Compound/complex commands From 9e24890de6a9f28939d8d06db572dd919a642900 Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Mon, 19 Jan 2015 22:49:07 -0500 Subject: [PATCH 29/84] Add alias for git pull --rebase --- git.scmbrc.example | 1 + lib/git/aliases.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/git.scmbrc.example b/git.scmbrc.example index e6566de..74f9db1 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -57,6 +57,7 @@ git_fetch_alias="gf" git_fetch_all_alias="gfa" git_fetch_and_rebase_alias="gfr" git_pull_alias="gpl" +git_pull_rebase_alias="gplr" git_push_alias="gps" git_push_force_alias="gpsf" git_pull_then_push_alias="gpls" diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index c7f8fc6..3addc1d 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -114,6 +114,7 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_fetch_alias" 'git' 'fetch' __git_alias "$git_checkout_branch_alias" 'git' 'checkout' '-b' __git_alias "$git_pull_alias" 'git' 'pull' + __git_alias "$git_pull_rebase_alias" 'git' 'pull' '--rebase' __git_alias "$git_push_alias" 'git' 'push' __git_alias "$git_push_force_alias" 'git' 'push' '-f' __git_alias "$git_status_original_alias" 'git' 'status' # (Standard git status) From 40e91b81ff0275cc8fbea5377e2715c29e0a7c53 Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Mon, 19 Jan 2015 22:52:57 -0500 Subject: [PATCH 30/84] Add alias for git diff -w -- --- git.scmbrc.example | 1 + lib/git/aliases.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/git.scmbrc.example b/git.scmbrc.example index e6566de..97fbbab 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -48,6 +48,7 @@ git_reset_hard_alias="grsh" git_rm_alias="grm" git_blame_alias="gbl" git_diff_alias="gd" +git_diff_no_whitespace_alias="gdnw" git_diff_word_alias="gdw" git_diff_cached_alias="gdc" git_difftool_alias="gdt" diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index c7f8fc6..78f1aaf 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -96,6 +96,7 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_rm_alias" 'git' 'rm' __git_alias "$git_blame_alias" 'git' 'blame' __git_alias "$git_diff_alias" 'git' 'diff' '--' + __git_alias "$git_diff_no_whitespace_alias" 'git' 'diff' '-w' '--' __git_alias "$git_diff_word_alias" 'git' 'diff' '--word-diff' __git_alias "$git_diff_cached_alias" 'git' 'diff' '--cached --' __git_alias "$git_add_patch_alias" 'git' 'add' '-p' From e9217f50ab0a0c6fa13e8989a87814ac5befe98c Mon Sep 17 00:00:00 2001 From: Stephan van Eijkelenburg Date: Thu, 7 May 2015 17:02:34 +0200 Subject: [PATCH 31/84] Fixes #168 (zsh-problems) This PR replaces `local varname=value` style declarations with `local varname; varname=value`. This solves #168 which caused troubles in zsh environments --- lib/git/aliases.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index c7f8fc6..80139f0 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -64,7 +64,8 @@ _git # Usage: __git_alias __git_alias () { if [ -n "$1" ]; then - local alias_str="$1"; local cmd_prefix="$2"; local cmd="$3"; local cmd_args=("${@:4}") + local alias_str cmd_prefix cmd cmd_args + alias_str="$1"; cmd_prefix="$2"; cmd="$3"; cmd_args=("${@:4}") alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }${cmd_args[*]}" if [ "$shell" = "bash" ]; then __define_git_completion "$alias_str" "$cmd" From bdf6096808e98838fee05353e054d1989c37d7b0 Mon Sep 17 00:00:00 2001 From: James Ravn Date: Sun, 10 May 2015 00:39:05 +0100 Subject: [PATCH 32/84] Fix quoting of semicolon and pipe --- lib/git/status_shortcuts.sh | 2 +- test/lib/git/status_shortcuts_test.sh | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index e5686c2..f77f066 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -158,7 +158,7 @@ _print_path() { # Execute a command with expanded args, e.g. Delete files 6 to 12: $ ge rm 6-12 # Fails if command is a number or range (probably not worth fixing) exec_scmb_expand_args() { - eval "$(scmb_expand_args "$@" | sed -e "s/\([][()<>^ \"']\)/"'\\\1/g')" + eval "$(scmb_expand_args "$@" | sed -e "s/\([][|;()<>^ \"']\)/"'\\\1/g')" } # Clear numbered env variables diff --git a/test/lib/git/status_shortcuts_test.sh b/test/lib/git/status_shortcuts_test.sh index aa86d2e..71eb5d5 100755 --- a/test/lib/git/status_shortcuts_test.sh +++ b/test/lib/git/status_shortcuts_test.sh @@ -60,6 +60,10 @@ test_scmb_expand_args() { "$(scmb_expand_args -ma "Test Commit Message" "Unquoted")" } +test_command_wrapping_escapes_special_characters() { + assertEquals 'should escape | the pipe' "$(exec_scmb_expand_args echo "should escape | the pipe")" + assertEquals 'should escape ; the semicolon' "$(exec_scmb_expand_args echo "should escape ; the semicolon")" +} test_git_status_shortcuts() { setupTestRepo @@ -252,10 +256,10 @@ test_git_commit_prompt() { assertIncludes "$git_show_output" "$commit_msg" # Test that history was appended correctly. - if [[ $shell == "zsh" ]]; then - test_history="$(history)" + if [[ $shell == "zsh" ]]; then + test_history="$(history)" else - test_history="$(cat $HISTFILE)" + test_history="$(cat $HISTFILE)" fi assertIncludes "$test_history" "$commit_msg" assertIncludes "$test_history" "git commit -m \"$dbl_escaped_msg\"" @@ -285,10 +289,10 @@ test_git_commit_prompt_with_append() { assertIncludes "$git_show_output" "$commit_msg \[ci skip\]" # Test that history was appended correctly. - if [[ $shell == "zsh" ]]; then - test_history="$(history)" + if [[ $shell == "zsh" ]]; then + test_history="$(history)" else - test_history="$(cat $HISTFILE)" + test_history="$(cat $HISTFILE)" fi assertIncludes "$test_history" "$commit_msg \[ci skip\]" assertIncludes "$test_history" "git commit -m \"$commit_msg \[ci skip\]\"" @@ -312,4 +316,3 @@ test_adding_files_with_spaces() { # load and run shUnit2 source "$scmbDir/test/support/shunit2" - From 1ef06aa9cdc7bbd01bb3f92dcf1e61d7cd9b2576 Mon Sep 17 00:00:00 2001 From: Armen Baghumian Date: Thu, 21 May 2015 04:09:57 +0000 Subject: [PATCH 33/84] Offset starts from 0 so the argument would be 3 This patch fixes broken aliases which have arguments (e.g. gap) --- lib/git/aliases.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 80139f0..562022b 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -65,7 +65,7 @@ _git __git_alias () { if [ -n "$1" ]; then local alias_str cmd_prefix cmd cmd_args - alias_str="$1"; cmd_prefix="$2"; cmd="$3"; cmd_args=("${@:4}") + alias_str="$1"; cmd_prefix="$2"; cmd="$3"; cmd_args=("${@:3}") alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }${cmd_args[*]}" if [ "$shell" = "bash" ]; then __define_git_completion "$alias_str" "$cmd" From d288f3cd74cfc01fcb0caf96b9817ddcc4450a67 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Mon, 25 May 2015 23:01:14 +0700 Subject: [PATCH 34/84] Fixed bug in __git_alias --- lib/git/aliases.sh | 2 +- lib/git/shell_shortcuts.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 562022b..80139f0 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -65,7 +65,7 @@ _git __git_alias () { if [ -n "$1" ]; then local alias_str cmd_prefix cmd cmd_args - alias_str="$1"; cmd_prefix="$2"; cmd="$3"; cmd_args=("${@:3}") + alias_str="$1"; cmd_prefix="$2"; cmd="$3"; cmd_args=("${@:4}") alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }${cmd_args[*]}" if [ "$shell" = "bash" ]; then __define_git_completion "$alias_str" "$cmd" diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 2388290..26a9ff4 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -108,7 +108,7 @@ fi # Function wrapper around 'll' # Adds numbered shortcuts to output of ls -l, just like 'git status' -if [ "$shell_ls_aliases_enabled" = "true" ]; then +if [ "$shell_ls_aliases_enabled" = "true" ] && which ruby > /dev/null 2>&1; then unalias ll > /dev/null 2>&1; unset -f ll > /dev/null 2>&1 function ls_with_file_shortcuts { local ll_output From ff4ae7932daa67bb62a57f04060da79941af56a7 Mon Sep 17 00:00:00 2001 From: Armen Baghumian Date: Tue, 26 May 2015 12:46:11 +0000 Subject: [PATCH 35/84] Fixed __git_alias bug in zsh --- lib/git/aliases.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 80139f0..7a55f70 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -66,6 +66,10 @@ __git_alias () { if [ -n "$1" ]; then local alias_str cmd_prefix cmd cmd_args alias_str="$1"; cmd_prefix="$2"; cmd="$3"; cmd_args=("${@:4}") + if [ "$shell" = "zsh" ]; then + cmd_args=("${@:3}") + fi + alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }${cmd_args[*]}" if [ "$shell" = "bash" ]; then __define_git_completion "$alias_str" "$cmd" From 5dd21beeea4198244b9b85d6920bee07b671f6db Mon Sep 17 00:00:00 2001 From: Armen Baghumian Date: Thu, 28 May 2015 13:04:44 +0000 Subject: [PATCH 36/84] Fixes 'git fetch' and 'git checkout' liases, closes #176 --- lib/git/aliases.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 7a55f70..37bb8a6 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -65,11 +65,9 @@ _git __git_alias () { if [ -n "$1" ]; then local alias_str cmd_prefix cmd cmd_args - alias_str="$1"; cmd_prefix="$2"; cmd="$3"; cmd_args=("${@:4}") - if [ "$shell" = "zsh" ]; then - cmd_args=("${@:3}") - fi - + alias_str="$1"; cmd_prefix="$2"; cmd="$3"; + shift 3 2>/dev/null + cmd_args=$@ alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }${cmd_args[*]}" if [ "$shell" = "bash" ]; then __define_git_completion "$alias_str" "$cmd" From 71f3086df9329fde55bedf7418621b91d411c8c2 Mon Sep 17 00:00:00 2001 From: Alexey Komnin Date: Wed, 3 Jun 2015 11:47:14 +0300 Subject: [PATCH 37/84] Fix setting alias for "_scmb_git_branch_shortcuts" __git_alias expects three arguments. Passing two arguments to __git_alias for "gb" leads to undesirable behaviour on some platforms. --- lib/git/branch_shortcuts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/branch_shortcuts.sh b/lib/git/branch_shortcuts.sh index 1e933b9..ceafb17 100644 --- a/lib/git/branch_shortcuts.sh +++ b/lib/git/branch_shortcuts.sh @@ -39,7 +39,7 @@ EOF done } -__git_alias "$git_branch_alias" "_scmb_git_branch_shortcuts" +__git_alias "$git_branch_alias" "_scmb_git_branch_shortcuts" "" __git_alias "$git_branch_all_alias" "_scmb_git_branch_shortcuts" "-a" __git_alias "$git_branch_move_alias" "_scmb_git_branch_shortcuts" "-m" __git_alias "$git_branch_delete_alias" "_scmb_git_branch_shortcuts" "-d" From 53aba36670aadd93504614e0f6e58dfdbaaa54e8 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 16 Jun 2015 17:20:29 +0700 Subject: [PATCH 38/84] Fix issue with aliases that have no args --- lib/git/aliases.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 37bb8a6..78368e8 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -65,9 +65,13 @@ _git __git_alias () { if [ -n "$1" ]; then local alias_str cmd_prefix cmd cmd_args + alias_str="$1"; cmd_prefix="$2"; cmd="$3"; - shift 3 2>/dev/null - cmd_args=$@ + if [ $# -gt 2 ]; then + shift 3 2>/dev/null + cmd_args=$@ + fi + alias $alias_str="$cmd_prefix $cmd${cmd_args:+ }${cmd_args[*]}" if [ "$shell" = "bash" ]; then __define_git_completion "$alias_str" "$cmd" From 6e28eb645a7d0bafdc604ccf81db7af3ca3f7cfd Mon Sep 17 00:00:00 2001 From: Patrick Brinich-Langlois Date: Sun, 23 Aug 2015 21:51:27 -0700 Subject: [PATCH 39/84] exec_scmb_expand_args: Escape ampersands. --- lib/git/status_shortcuts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index f77f066..c0fb549 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -158,7 +158,7 @@ _print_path() { # Execute a command with expanded args, e.g. Delete files 6 to 12: $ ge rm 6-12 # Fails if command is a number or range (probably not worth fixing) exec_scmb_expand_args() { - eval "$(scmb_expand_args "$@" | sed -e "s/\([][|;()<>^ \"']\)/"'\\\1/g')" + eval "$(scmb_expand_args "$@" | sed -e "s/\([][|;()<>^ \"'&]\)/"'\\\1/g')" } # Clear numbered env variables From 56640c0e4d24fa14c5beec695505a8edf58c5464 Mon Sep 17 00:00:00 2001 From: Brian Peiris Date: Wed, 9 Sep 2015 12:26:36 -0400 Subject: [PATCH 40/84] Add note about ruby in installation section. --- README.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.markdown b/README.markdown index e79f2e8..a2e7c53 100644 --- a/README.markdown +++ b/README.markdown @@ -297,6 +297,8 @@ The install script creates required default configs and adds the following line `[ -s "$HOME/.scm_breeze/scm_breeze.sh" ] && source "$HOME/.scm_breeze/scm_breeze.sh"` +**Note:** SCM Breeze performs much faster if you have ruby installed. + # Updating From 5fb222912db75430ccb1d925485d55fad13d4b73 Mon Sep 17 00:00:00 2001 From: Brian Peiris Date: Wed, 9 Sep 2015 12:36:17 -0400 Subject: [PATCH 41/84] Add table of contents to README The README has gotten quite large. Adding a table of contents might help, especially if you're just looking for the installation section. Generated using DocToc: https://github.com/thlorenz/doctoc --- README.markdown | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index e79f2e8..2cdacfb 100644 --- a/README.markdown +++ b/README.markdown @@ -1,11 +1,38 @@ # SCM Breeze [![TravisCI](https://secure.travis-ci.org/ndbroadbent/scm_breeze.png?branch=master)](http://travis-ci.org/ndbroadbent/scm_breeze) -### Streamline your SCM workflow. + +> Streamline your SCM workflow. **SCM Breeze** is a set of shell scripts (for `bash` and `zsh`) that enhance your interaction with git. It integrates with your shell to give you numbered file shortcuts, a repository index with tab completion, and many other useful features.
+- [SCM Breeze](#scm-breeze-) + - [Demos](#demos) + - [File Shortcuts](#file-shortcuts) + - [Git Status Shortcuts:](#git-status-shortcuts) + - ['ls' shortcuts:](#ls-shortcuts) + - [Other shortcuts](#other-shortcuts) + - [Keyboard bindings](#keyboard-bindings) + - [Repository Index](#repository-index) + - [Linking External Project Design Directories](#linking-external-project-design-directories) + - [1) Create and configure a root design directory](#1-create-and-configure-a-root-design-directory) + - [2) Initialize design directories for your projects](#2-initialize-design-directories-for-your-projects) + - [3) Link existing design directories into your projects](#3-link-existing-design-directories-into-your-projects) + - [Contributing tools / scripts](#contributing-tools--scripts) +- [Installation](#installation) +- [Updating](#updating) +- [Uninstall](#uninstall) +- [Configuration](#configuration) + - [1) Configure and use the provided SCM Breeze aliases](#1-configure-and-use-the-provided-scm-breeze-aliases) + - [2) Use your own aliases](#2-use-your-own-aliases) +- [Notes about Tab Completion for Aliases](#notes-about-tab-completion-for-aliases) + - [Bash](#bash) + - [Zsh](#zsh) +- [Contributing](#contributing) + +
+ ## Demos Adding a range of files, and pressing `Ctrl+X, C` to commit: @@ -363,5 +390,5 @@ Please feel free to fork and send pull requests, especially if you would like to for Mercurial, SVN, etc. -## Enjoy! +***Enjoy!*** From 80867427687649de2a15e32fc98ccaae746357d0 Mon Sep 17 00:00:00 2001 From: Aswinkumar Rajendiran Date: Wed, 14 Oct 2015 18:09:28 -0700 Subject: [PATCH 42/84] Change gd to be 'git diff' without the two dashes. Add a new alias gdf for 'git diff --' --- git.scmbrc.example | 1 + lib/git/aliases.sh | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/git.scmbrc.example b/git.scmbrc.example index e6566de..fde36dd 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -48,6 +48,7 @@ git_reset_hard_alias="grsh" git_rm_alias="grm" git_blame_alias="gbl" git_diff_alias="gd" +git_diff_file_alias="gdf" git_diff_word_alias="gdw" git_diff_cached_alias="gdc" git_difftool_alias="gdt" diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 78368e8..be15eff 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -102,7 +102,8 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_reset_hard_alias" 'git' 'reset' '--hard' __git_alias "$git_rm_alias" 'git' 'rm' __git_alias "$git_blame_alias" 'git' 'blame' - __git_alias "$git_diff_alias" 'git' 'diff' '--' + __git_alias "$git_diff_alias" 'git' 'diff' + __git_alias "$git_diff_file_alias" 'git' 'diff' '--' __git_alias "$git_diff_word_alias" 'git' 'diff' '--word-diff' __git_alias "$git_diff_cached_alias" 'git' 'diff' '--cached --' __git_alias "$git_add_patch_alias" 'git' 'add' '-p' From 65daecb0c73fa956eee0ac275f0d2690ae842dff Mon Sep 17 00:00:00 2001 From: Zack Sheppard Date: Sat, 28 Nov 2015 12:12:22 -0500 Subject: [PATCH 43/84] Support for OS X .bash_profile + install logging Adds support for OS X's default bash configuration file, ~/.bash_profile, and more logging during install about which file, if any, got the source line added. --- install.sh | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 31f4631..dd025ef 100755 --- a/install.sh +++ b/install.sh @@ -10,11 +10,19 @@ fi # This loads SCM Breeze into the shell session. exec_string="[ -s \"$HOME/.scm_breeze/scm_breeze.sh\" ] && source \"$HOME/.scm_breeze/scm_breeze.sh\"" -# Add line to bashrc and zshrc if not already present. -for rc in bashrc zshrc; do - if [ -s "$HOME/.$rc" ] && ! grep -q "$exec_string" "$HOME/.$rc"; then - printf "\n$exec_string\n" >> "$HOME/.$rc" - printf "== Added SCM Breeze to '~/.$rc'\n" +# Add line to bashrc, zshrc, and bash_profile if not already present. +added_to_profile=false +already_present=false +for rc in bashrc zshrc bash_profile; do + if [ -s "$HOME/.$rc" ]; then + if grep -q "$exec_string" "$HOME/.$rc"; then + printf "== Already installed in '~/.$rc'\n" + already_present=true + else + printf "\n$exec_string\n" >> "$HOME/.$rc" + printf "== Added SCM Breeze to '~/.$rc'\n" + added_to_profile=true + fi fi done @@ -23,5 +31,12 @@ source "$scmbDir/lib/scm_breeze.sh" # Create '~/.*.scmbrc' files from example files _create_or_patch_scmbrc - -echo "== Run 'source ~/.bashrc' or 'source ~/.zshrc' to load SCM Breeze into your current shell." +if [ "$added_to_profile" = true ] || [ "$already_present" = true ]; then + echo "== SCM Breeze Installed! Run 'source ~/.bashrc || source ~/.bash_profile' or 'source ~/.zshrc'" + echo " to load SCM Breeze into your current shell." +else + echo "== Error:" + echo " Found no profile to add SCM Breeze to." + echo " Add line to your shell profile and source it to install manually:" + printf " $exec_string\n" +fi From 747b60cf3756ac26912cb2534fcdc89e6a19abeb Mon Sep 17 00:00:00 2001 From: Tyler Levine Date: Mon, 14 Mar 2016 12:45:00 -0700 Subject: [PATCH 44/84] Use >| operator in _rebuild_git_index when overwriting .git_index file If the shell has the noclobber option set, s --rebuild will fail to update the .git_index file. Using the >| operator instead of the > operator forces the .git_index file to be clobbered, which is the desired behavior. --- lib/git/repo_index.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/repo_index.sh b/lib/git/repo_index.sh index 44964f9..bf37b55 100644 --- a/lib/git/repo_index.sh +++ b/lib/git/repo_index.sh @@ -149,7 +149,7 @@ function _rebuild_git_index() { IFS=$'\n' for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do echo $(basename $repo | sed "s/ /_/g") $repo - done | sort | cut -d " " -f2- > "$GIT_REPO_DIR/.git_index" + done | sort | cut -d " " -f2- >| "$GIT_REPO_DIR/.git_index" IFS=$' \t\n' if [ "$1" != "--silent" ]; then From 62d8df8371e16134d8f7ebd0b8fc28580568f701 Mon Sep 17 00:00:00 2001 From: shinriyo Date: Wed, 16 Mar 2016 18:09:42 +0900 Subject: [PATCH 45/84] top level path shortcut top level path shortcut "gtop" --- lib/git/aliases.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 78368e8..0f94cc0 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -133,6 +133,7 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_rebase_alias_continue" 'git' 'rebase' '--continue' __git_alias "$git_rebase_alias_abort" 'git' 'rebase' '--abort' __git_alias "$git_reset_last_commit" 'git' 'reset HEAD~' + __git_alias "$git_top_level_alias" 'git' 'rev-parse' '--show-toplevel' __git_alias "$git_merge_alias" 'git' 'merge' __git_alias "$git_merge_no_fast_forward_alias" 'git' 'merge' '--no-ff' __git_alias "$git_merge_only_fast_forward_alias" 'git' 'merge' '--ff' @@ -145,7 +146,6 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_stash_list_alias" 'git' 'stash' 'list' __git_alias "$git_tag_alias" 'git' 'tag' - # Compound/complex commands _alias "$git_fetch_all_alias" 'git fetch --all' _alias "$git_pull_then_push_alias" 'git pull && git push' From 39609d34278b88c64768cd0de41268e97507b8fa Mon Sep 17 00:00:00 2001 From: shinriyo Date: Wed, 16 Mar 2016 18:10:30 +0900 Subject: [PATCH 46/84] gtop shortcut gtop shortcut --- git.scmbrc.example | 1 + 1 file changed, 1 insertion(+) diff --git a/git.scmbrc.example b/git.scmbrc.example index e6566de..b65b4df 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -95,6 +95,7 @@ git_stash_apply_alias="gasha" git_stash_pop_alias="gashp" git_stash_list_alias="gashl" git_tag_alias="gt" +git_top_level_alias="gtop" # Hub aliases (https://github.com/github/hub) git_pull_request_alias="gpr" From 0d80de33e675dcaec0f60b994f1d74c9dcd9603c Mon Sep 17 00:00:00 2001 From: Brian Peiris Date: Mon, 11 Apr 2016 05:10:36 -0400 Subject: [PATCH 47/84] Fix infinite loop in shell with babun (cygwin) --- lib/git/fallback/status_shortcuts_shell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 lib/git/fallback/status_shortcuts_shell.sh diff --git a/lib/git/fallback/status_shortcuts_shell.sh b/lib/git/fallback/status_shortcuts_shell.sh old mode 100644 new mode 100755 index 86c6694..e7cce4b --- a/lib/git/fallback/status_shortcuts_shell.sh +++ b/lib/git/fallback/status_shortcuts_shell.sh @@ -127,7 +127,7 @@ _gs_output_file_group() { if [ -z "$project_root" ]; then relative="${stat_file[$i]}" else - dest="$project_root/${stat_file[$i]}" + dest=$(readlink -f "$project_root/${stat_file[$i]}") local pwd=$(readlink -f "$PWD") relative="$(_gs_relative_path "$pwd" "$dest" )" fi From 472a24e1c525b38da9a6c5bb590be201b9a139a5 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 14 May 2016 22:10:08 +0700 Subject: [PATCH 48/84] Added maintenance notice --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index e79f2e8..7f827b9 100644 --- a/README.markdown +++ b/README.markdown @@ -1,3 +1,7 @@ +# Sorry, I don't really work on this anymore. + +## I still use it every day but it does everything I need. + # SCM Breeze [![TravisCI](https://secure.travis-ci.org/ndbroadbent/scm_breeze.png?branch=master)](http://travis-ci.org/ndbroadbent/scm_breeze) ### Streamline your SCM workflow. From 987da4d6a273da155b88a5bbbea503c6f23a9247 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 14 May 2016 22:22:20 +0700 Subject: [PATCH 49/84] Skip env variables for git branch if there are more than 300 branches --- lib/git/branch_shortcuts.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/git/branch_shortcuts.sh b/lib/git/branch_shortcuts.sh index ceafb17..25ee7f0 100644 --- a/lib/git/branch_shortcuts.sh +++ b/lib/git/branch_shortcuts.sh @@ -13,8 +13,9 @@ unalias $git_branch_alias > /dev/null 2>&1; unset -f $git_branch_alias > /dev/null 2>&1 function _scmb_git_branch_shortcuts { fail_if_not_git_repo || return 1 + # Fall back to normal git branch, if any unknown args given - if [[ -n "$@" ]] && [[ "$@" != "-a" ]]; then + if [[ "$($_git_cmd branch | wc -l)" -gt 300 ]] || ([[ -n "$@" ]] && [[ "$@" != "-a" ]]); then exec_scmb_expand_args $_git_cmd branch "$@" return 1 fi From 47a0b6c7244da7f14fa46858e2c054d2047dd354 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 14 May 2016 22:31:43 +0700 Subject: [PATCH 50/84] Add git whatchanged alias (gwc), thanks tjlevine (#196) --- git.scmbrc.example | 1 + lib/git/aliases.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/git.scmbrc.example b/git.scmbrc.example index 546631c..208229d 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -97,6 +97,7 @@ git_stash_pop_alias="gashp" git_stash_list_alias="gashl" git_tag_alias="gt" git_top_level_alias="gtop" +git_whatchanged_alias="gwc" # Hub aliases (https://github.com/github/hub) git_pull_request_alias="gpr" diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 47df043..ee7051a 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -146,6 +146,7 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_stash_pop_alias" 'git' 'stash' 'pop' __git_alias "$git_stash_list_alias" 'git' 'stash' 'list' __git_alias "$git_tag_alias" 'git' 'tag' + __git_alias "$git_whatchanged_alias" 'git' 'whatchanged' # Compound/complex commands _alias "$git_fetch_all_alias" 'git fetch --all' From c655ace09c6b4b135e89d95646e6fb1520c86774 Mon Sep 17 00:00:00 2001 From: Emmanuel B Date: Wed, 6 Jul 2016 07:53:18 -0400 Subject: [PATCH 51/84] added 'git apply' alias --- git.scmbrc.example | 1 + lib/git/aliases.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/git.scmbrc.example b/git.scmbrc.example index a9bed89..e73bcef 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -100,6 +100,7 @@ git_stash_list_alias="gashl" git_tag_alias="gt" git_top_level_alias="gtop" git_whatchanged_alias="gwc" +git_apply_alias="gapp" # Hub aliases (https://github.com/github/hub) git_pull_request_alias="gpr" diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index d09db2c..8fc177d 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -149,6 +149,7 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_stash_list_alias" 'git' 'stash' 'list' __git_alias "$git_tag_alias" 'git' 'tag' __git_alias "$git_whatchanged_alias" 'git' 'whatchanged' + __git_alias "$git_apply_alias" 'git' 'apply' # Compound/complex commands _alias "$git_fetch_all_alias" 'git fetch --all' From db08d3092866345953967209990fbb7fb5f4099f Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 17 Aug 2016 14:59:58 +0700 Subject: [PATCH 52/84] Updated README --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 68972b3..759c179 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ -# Sorry, I don't really work on this anymore. +# Moved to an organization, and looking for maintainers. -## I still use it every day but it does everything I need. +## Please post an issue if you would like to help with maintainance. # SCM Breeze [![TravisCI](https://secure.travis-ci.org/ndbroadbent/scm_breeze.png?branch=master)](http://travis-ci.org/ndbroadbent/scm_breeze) From 49dca42056f789041983d35d3798cce91934e06a Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 17 Aug 2016 15:00:37 +0700 Subject: [PATCH 53/84] Remove "gh" alias --- lib/git/aliases.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index d09db2c..0dad159 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -20,7 +20,9 @@ unset -f git > /dev/null 2>&1 export _git_cmd="$(\which git)" # Wrap git with the 'hub' github wrapper, if installed (https://github.com/defunkt/hub) if type hub > /dev/null 2>&1; then export _git_cmd="hub"; fi -if type gh > /dev/null 2>&1; then export _git_cmd="gh"; fi + +# gh is now deprecated, and merged into the `hub` command line tool. +#if type gh > /dev/null 2>&1; then export _git_cmd="gh"; fi # Create 'git' function that calls hub if defined, and expands all numeric arguments function git(){ From 0dd155b57a738b4f7a3bdd77039befcd89aaa14c Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Wed, 17 Aug 2016 15:01:32 +0700 Subject: [PATCH 54/84] Another update --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 759c179..f2607bf 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ -# Moved to an organization, and looking for maintainers. +# Now looking for help with maintainance. -## Please post an issue if you would like to help with maintainance. +## Please post an issue if you would like to help out. # SCM Breeze [![TravisCI](https://secure.travis-ci.org/ndbroadbent/scm_breeze.png?branch=master)](http://travis-ci.org/ndbroadbent/scm_breeze) From 942f2bdd908c29d69d0fd4784546b442036dd37a Mon Sep 17 00:00:00 2001 From: Antti Salminen Date: Sat, 9 Jan 2016 13:41:38 +0200 Subject: [PATCH 55/84] Expand arguments for git difftool. --- lib/git/aliases.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 4ba816d..4cbdaed 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -28,7 +28,7 @@ if type hub > /dev/null 2>&1; then export _git_cmd="hub"; fi function git(){ # Only expand args for git commands that deal with paths or branches case $1 in - commit|blame|add|log|rebase|merge) + commit|blame|add|log|rebase|merge|difftool) exec_scmb_expand_args "$_git_cmd" "$@";; checkout|diff|rm|reset) exec_scmb_expand_args --relative "$_git_cmd" "$@";; From 121803b857304b091a3437131a7c72470a46cf87 Mon Sep 17 00:00:00 2001 From: Wilhelmina Drengwitz Date: Sun, 28 Aug 2016 15:29:29 -0400 Subject: [PATCH 56/84] Fix invalid use of `return` in bash test runner --- run_tests.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index fff4438..9aebd4c 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -12,8 +12,8 @@ done if [ "$failed" = "true" ]; then echo "Tests failed!" - return 1; + false else echo "All tests passed!" - return 0; -fi \ No newline at end of file + true +fi From b5606ed897783d65f5995b747cd1f12ec8d7000d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Baumho=CC=88ver?= Date: Tue, 1 Nov 2016 13:33:50 +0100 Subject: [PATCH 57/84] changed alias for git_log_stat_alias from gls to glst due to issue with recent zsh update --- git.scmbrc.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git.scmbrc.example b/git.scmbrc.example index 2728b5a..e04e9b3 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -89,7 +89,7 @@ git_merge_only_fast_forward_alias="gmff" git_cherry_pick_alias="gcp" git_log_alias="gl" git_log_all_alias="gla" -git_log_stat_alias="gls" +git_log_stat_alias="glst" git_log_graph_alias="glg" git_show_alias="gsh" git_show_summary="gsm" # (gss taken by git status short) From 76fc67b9fd12ed249a434c49c9607426d76ca489 Mon Sep 17 00:00:00 2001 From: Andy Zhang Date: Mon, 14 Nov 2016 11:30:06 -0800 Subject: [PATCH 58/84] Bump git index depth to 5 for golang src structure --- lib/git/repo_index.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/repo_index.sh b/lib/git/repo_index.sh index bf37b55..c77d115 100644 --- a/lib/git/repo_index.sh +++ b/lib/git/repo_index.sh @@ -127,7 +127,7 @@ _git_index_dirs_without_home() { function _find_git_repos() { # Find all unarchived projects IFS=$'\n' - for repo in $(find -L "$GIT_REPO_DIR" -maxdepth 4 -name ".git" -type d \! -wholename '*/archive/*'); do + for repo in $(find -L "$GIT_REPO_DIR" -maxdepth 5 -name ".git" -type d \! -wholename '*/archive/*'); do echo ${repo%/.git} # Return project folder, with trailing ':' _find_git_submodules $repo # Detect any submodules done From 1a5d3f52e088254fd7f7bcc530aae3ff3f7cf255 Mon Sep 17 00:00:00 2001 From: Martino Visintin Date: Sat, 21 Jan 2017 16:36:33 +0000 Subject: [PATCH 59/84] change install path to org repo --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index f2607bf..d2642ba 100644 --- a/README.markdown +++ b/README.markdown @@ -319,7 +319,7 @@ It would be cool to make this project into an [oh-my-zsh](https://github.com/rob # Installation ```bash -git clone git://github.com/ndbroadbent/scm_breeze.git ~/.scm_breeze +git clone git://github.com/scmbreeze/scm_breeze.git ~/.scm_breeze ~/.scm_breeze/install.sh source ~/.bashrc # or source ~/.zshrc ``` From 1c072b335414bfe5563d35b9fb6a4ac1019f6bd6 Mon Sep 17 00:00:00 2001 From: Martino Visintin Date: Fri, 27 Jan 2017 20:50:13 +0000 Subject: [PATCH 60/84] reorganize readme - lines are now ~= 80 chars - update links to point to scmbreeze/scm_breeze - update travis banner link - promote install instructions to top-ish of readme - consolidate contributing section - remove some horizontal lines --- README.markdown | 344 +++++++++++++++++++++++++----------------------- 1 file changed, 182 insertions(+), 162 deletions(-) diff --git a/README.markdown b/README.markdown index d2642ba..ca83466 100644 --- a/README.markdown +++ b/README.markdown @@ -2,17 +2,22 @@ ## Please post an issue if you would like to help out. -# SCM Breeze [![TravisCI](https://secure.travis-ci.org/ndbroadbent/scm_breeze.png?branch=master)](http://travis-ci.org/ndbroadbent/scm_breeze) +--- + +# SCM Breeze [![TravisCI](https://secure.travis-ci.org/scmbreeze/scm_breeze.png?branch=master)](http://travis-ci.org/scmbreeze/scm_breeze) > Streamline your SCM workflow. -**SCM Breeze** is a set of shell scripts (for `bash` and `zsh`) that enhance your interaction with git. It integrates with your shell to give you numbered file shortcuts, -a repository index with tab completion, and many other useful features. +**SCM Breeze** is a set of shell scripts (for `bash` and `zsh`) that enhance +your interaction with git. It integrates with your shell to give you numbered +file shortcuts, a repository index with tab completion, and many other useful +features. -
+![SCM Breeze Example Gif](http://i.imgur.com/3fD8cpo.gif) -- [SCM Breeze](#scm-breeze-) - - [Demos](#demos) + +- [Installation](#installation) +- [Usage](#usage) - [File Shortcuts](#file-shortcuts) - [Git Status Shortcuts:](#git-status-shortcuts) - ['ls' shortcuts:](#ls-shortcuts) @@ -23,56 +28,66 @@ a repository index with tab completion, and many other useful features. - [1) Create and configure a root design directory](#1-create-and-configure-a-root-design-directory) - [2) Initialize design directories for your projects](#2-initialize-design-directories-for-your-projects) - [3) Link existing design directories into your projects](#3-link-existing-design-directories-into-your-projects) - - [Contributing tools / scripts](#contributing-tools--scripts) -- [Installation](#installation) -- [Updating](#updating) -- [Uninstall](#uninstall) - [Configuration](#configuration) - - [1) Configure and use the provided SCM Breeze aliases](#1-configure-and-use-the-provided-scm-breeze-aliases) - - [2) Use your own aliases](#2-use-your-own-aliases) + - [1) Configure and use the provided SCM Breeze aliases](#1-configure-and-use-the-provided-scm-breeze-aliases) + - [2) Use your own aliases](#2-use-your-own-aliases) +- [Updating](#updating) +- [Uninstalling](#uninstalling) - [Notes about Tab Completion for Aliases](#notes-about-tab-completion-for-aliases) - [Bash](#bash) - [Zsh](#zsh) - [Contributing](#contributing) -
-## Demos +## Installation -Adding a range of files, and pressing `Ctrl+X, C` to commit: +```bash +git clone git://github.com/scmbreeze/scm_breeze.git ~/.scm_breeze +~/.scm_breeze/install.sh +source ~/.bashrc # or source ~/.zshrc +``` -
+The install script creates required default configs and adds the following line +to your `.bashrc` or `.zshrc`: -
+`[ -s "$HOME/.scm_breeze/scm_breeze.sh" ] && source "$HOME/.scm_breeze/scm_breeze.sh"` -
- -
- -## File Shortcuts - -SCM Breeze makes it really easy to work with changed files, and groups of changed files. -Whenever you view your SCM status, each modified path is stored in a numbered environment variable. -You can configure the variable prefix, which is 'e' by default. +**Note:** SCM Breeze performs much faster if you have ruby installed. -### Git Status Shortcuts: +## Usage + +
+ +### File Shortcuts + +SCM Breeze makes it really easy to work with changed files, and groups of +changed files. Whenever you view your SCM status, each modified path is stored +in a numbered environment variable. You can configure the variable prefix, +which is 'e' by default. + + +#### Git Status Shortcuts:
Git Status With Shortcuts

-### 'ls' shortcuts: + +#### 'ls' shortcuts:
Ls With Shortcuts

-These numbers (or ranges of numbers) can be used with any SCM or system command. +These numbers (or ranges of numbers) can be used with any SCM or system +command. -For example, if `ga` was your alias for `git add`, instead of typing something like: +For example, if `ga` was your alias for `git add`, instead of typing something +like: ```bash $ ga assets/git_breeze/config* assets/git_breeze/install.sh @@ -84,8 +99,8 @@ You can type this instead: $ ga $e2 $e3 $e11 ``` -But SCM Breeze aliases `ga` to the `git_add_shortcuts` function, -which is smart enough to expand integers and ranges, so all you need to type is: +But SCM Breeze aliases `ga` to the `git_add_shortcuts` function, which is smart +enough to expand integers and ranges, so all you need to type is: ```bash $ ga 2 3 11 @@ -97,8 +112,8 @@ And if you want to add all unstaged changes (files 1 to 10): $ ga 1-10 ``` -(Note that `ga` will also remove deleted files, unlike the standard `git add` command. -This behaviour can be turned off if you don't like it.) +(Note that `ga` will also remove deleted files, unlike the standard `git add` +command. This behaviour can be turned off if you don't like it.) You can also diff, reset or checkout a file by typing: @@ -110,8 +125,8 @@ $ gco 5 ``` -You can use these shortcuts with system commands by passing your command through `exec_scmb_expand_args` -(default alias is 'ge'): +You can use these shortcuts with system commands by passing your command +through `exec_scmb_expand_args` (default alias is 'ge'): ```bash @@ -125,19 +140,21 @@ $ ge echo 1-3 ``` -### Other shortcuts +#### Other shortcuts -SCM Breeze adds a number of aliases to your shell. Use `list_aliases` to view all the aliases and their corresponding commands. -You can filter aliases by adding a search string: `list_aliases git log` +SCM Breeze adds a number of aliases to your shell. Use `list_aliases` to view +all the aliases and their corresponding commands. You can filter aliases by +adding a search string: `list_aliases git log` -There's also a `git_aliases` command, which just shows aliases for `git` commands. You can also pass in additional filters, e.g. `git_aliases log`. +There's also a `git_aliases` command, which just shows aliases for `git` +commands. You can also pass in additional filters, e.g. `git_aliases log`. -## Keyboard bindings +### Keyboard bindings -Some of my most common git commands are `git add` and `git commit`, so I wanted these -to be as streamlined as possible. One way of speeding up commonly used commands is by binding them to -keyboard shortcuts. +Some of my most common git commands are `git add` and `git commit`, so I wanted +these to be as streamlined as possible. One way of speeding up commonly used +commands is by binding them to keyboard shortcuts. Here are the default key bindings: @@ -145,14 +162,13 @@ Here are the default key bindings: * `CTRL`+`x` `SPACE` => `git_commit_all` - commit everything -The commit shortcuts use the `git_commit_prompt` function, which gives a simple prompt like this: +The commit shortcuts use the `git_commit_prompt` function, which gives a simple +prompt like this: -
-Git Commit All -
-
-(When using bash, this commit prompt gives you access to your bash history via the arrow keys.) -
+

(When using bash, this commit prompt gives +you access to your bash history via the arrow keys.)
And if you really want to speed up your workflow, you can type this: @@ -168,23 +184,26 @@ This sends the `HOME` key, followed by `git_add_and_commit`:
-## Repository Index +### Repository Index -The second feature is a repository index for all of your projects and submodules. -This gives you super-fast switching between your project directories, with tab completion, -and it can even tab-complete down to project subdirectories. -This means that you can keep your projects organized in subfolders, -but switch between them as easily as if they were all in one folder. +The second feature is a repository index for all of your projects and +submodules. This gives you super-fast switching between your project +directories, with tab completion, and it can even tab-complete down to project +subdirectories. This means that you can keep your projects organized in +subfolders, but switch between them as easily as if they were all in one +folder. -It's similar to [autojump](https://github.com/joelthelion/autojump), but it doesn't need to 'learn' anything, -and it can do SCM-specific stuff like: +It's similar to [autojump](https://github.com/joelthelion/autojump), but it +doesn't need to 'learn' anything, and it can do SCM-specific stuff like: -* Running a command for all of your repos (useful if you ever need to update a lot of remote URLs) +* Running a command for all of your repos (useful if you ever need to update a + lot of remote URLs) * Update all of your repositories via a cron task The default alias for `git_index` is 'c', which might stand for 'code' -You will first need to configure your repository directory, and then build the index: +You will first need to configure your repository directory, and then build the +index: ```bash $ c --rebuild @@ -192,10 +211,12 @@ $ c --rebuild # => ===== Indexed 64 repos in /home/ndbroadbent/code/.git_index ``` -Then you'll be able to switch between your projects, or show the list of indexed repos. +Then you'll be able to switch between your projects, or show the list of +indexed repos. -To switch to a project directory, you don't need to type the full project name. For example, -to switch to the `capistrano` project, you could type any of the following: +To switch to a project directory, you don't need to type the full project name. +For example, to switch to the `capistrano` project, you could type any of the +following: ```bash $ c capistrano @@ -214,19 +235,20 @@ $ c capistrano/lib/ # => cd ~/code/gems/capistrano/lib ``` -Or if you want to go to a subdirectory within the `~/code` directory, prefix the first argument with a `/`: +Or if you want to go to a subdirectory within the `~/code` directory, prefix +the first argument with a `/`: ```bash ~ $ c /gems ~/code/gems $ ``` -## Linking External Project Design Directories +### Linking External Project Design Directories -When you're creating logos or icons for a project that uses `git`, -have you ever wondered where you should store those `.psd` or `.xcf` files? -Do you commit all of your raw design files, or does it put you off that any changes to those files -will bloat your repository? +When you're creating logos or icons for a project that uses `git`, have you +ever wondered where you should store those `.psd` or `.xcf` files? Do you +commit all of your raw design files, or does it put you off that any changes to +those files will bloat your repository? Here were my goals when I set out to find a solution: @@ -235,166 +257,164 @@ Here were my goals when I set out to find a solution: * The design directory needed to be synchronized across all of my machines The simplest way for me to synchronize files was via my Dropbox account. -However, if you work with a larger team, you could set up a shared design directory on one -of your servers and synchronize it with `rsync`. +However, if you work with a larger team, you could set up a shared design +directory on one of your servers and synchronize it with `rsync`. -### 1) Create and configure a root design directory +#### 1) Create and configure a root design directory I created my root design directory at `~/Dropbox/Design`. -After you've created your root design directory, edit `~/.scmbrc` and set `root_design_dir` -to the directory you just created. -You can also configure the design directory that's created in each of your projects -(default: `design_assets`), as well as the subdirectories you would like to use. -The default base subdirectories are: Images, Backgrounds, Logos, Icons, Mockups, and Screenshots. +After you've created your root design directory, edit `~/.scmbrc` and set +`root_design_dir` to the directory you just created. You can also configure +the design directory that's created in each of your projects (default: +`design_assets`), as well as the subdirectories you would like to use. The +default base subdirectories are: Images, Backgrounds, Logos, Icons, Mockups, +and Screenshots. -After you have changed these settings, remember to run `source ~/.bashrc` or `source ~/.zshrc`. +After you have changed these settings, remember to run `source ~/.bashrc` or +`source ~/.zshrc`. -### 2) Initialize design directories for your projects +#### 2) Initialize design directories for your projects -To set up the design directories and symlinks, go to a project's directory and run: +To set up the design directories and symlinks, go to a project's directory and +run: ```bash design init ``` If your root directory is `~/Dropbox/Design`, directories will be created at -`~/Dropbox/Design/projects/my_project/Backgrounds`, `~/Dropbox/Design/projects/my_project/Icons`, etc. +`~/Dropbox/Design/projects/my_project/Backgrounds`, +`~/Dropbox/Design/projects/my_project/Icons`, etc. -It will then symlink the project from your root design directory into your project's design directory, -so you end up with: +It will then symlink the project from your root design directory into your +project's design directory, so you end up with: * `my_project/design_assets` -> `~/Dropbox/Design/projects/my_project` It also adds this directory to `.git/info/exclude` so that git ignores it. -If you use the git repository index, -you can run the following batch command to set up these directories for all of your git repos at once: +If you use the git repository index, you can run the following batch command to +set up these directories for all of your git repos at once: ```bash git_index --batch-cmd design init ``` - If you want to remove any empty design directories, run: ```bash design trim ``` -And if you want to remove all of a project's design directories, even if they contain files: +And if you want to remove all of a project's design directories, even if they +contain files: ```bash design rm ``` -### 3) Link existing design directories into your projects +#### 3) Link existing design directories into your projects -If you've set up your design directories on one machine, you'll want them -to be synchronized across all of your other development machines. +If you've set up your design directories on one machine, you'll want them to be +synchronized across all of your other development machines. -Just run the following command on your other machines after you've configured the root design directory: +Just run the following command on your other machines after you've configured +the root design directory: ```bash design link ``` -This uses your git index to figure out where to create the symlinks. -If you don't use the git index, the same outcome could be achieved by running 'design init' -for each of the projects. +This uses your git index to figure out where to create the symlinks. If you +don't use the git index, the same outcome could be achieved by running 'design +init' for each of the projects. +## Configuration -## Contributing tools / scripts +SCM Breeze is configured via automatically installed `~/.*.scmbrc` files. To +change git configuration, edit `~/.git.scmbrc`. -If you have any awesome SCM scripts lurking in your `.bashrc` or `.zshrc`, -please feel free to send me a pull request. -It would be cool to make this project into an [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) for SCMs. +Each feature is modular, so you are free to ignore the parts you don't want to +use. Just comment out the relevant line in `~/.scm_breeze/scm_breeze.sh`. + +**Note:** After changing any settings, you will need to run `source ~/.bashrc` +(or `source ~/.zshrc`) + +I know we grow attached to the aliases we use every day, so I've made the alias +system completely customizable. You have two options when it comes to aliases: -# Installation +### 1) Configure and use the provided SCM Breeze aliases -```bash -git clone git://github.com/scmbreeze/scm_breeze.git ~/.scm_breeze -~/.scm_breeze/install.sh -source ~/.bashrc # or source ~/.zshrc -``` - -The install script creates required default configs and adds the following line to your `.bashrc` or `.zshrc`: - -`[ -s "$HOME/.scm_breeze/scm_breeze.sh" ] && source "$HOME/.scm_breeze/scm_breeze.sh"` - -**Note:** SCM Breeze performs much faster if you have ruby installed. +Just tweak the aliases in `~/.git.scmbrc`. You can also change or remove any +keyboard shortcuts. These aliases also come with tab completion. For example, +you can type `gco ` to tab complete your list of branches. -# Updating +### 2) Use your own aliases -Please run `update_scm_breeze` to fetch the latest code. This will update SCM Breeze from Github, -and will create or patch your `~/.*.scmbrc` config files if any new settings are added. +In your `git.scmbrc` config file, just set the `git_setup_aliases` option to +`no`. Your existing git aliases will then be used, and you will still be able +to use the numeric shortcuts feature. SCM Breeze creates a function to wrap +the 'git' command, which expands numeric arguments, and uses `hub` if +available. -# Uninstall +A few aliases will still be defined for the central SCM Breeze features, such +as `gs` for the extended `git status`, and `ga` for the `git add` function. + +If you already have an alias like `alias gco="git checkout"`, you can now type +`gco 1` to checkout the first file in the output of SCM Breeze's `git status`. + + +## Notes about Tab Completion for Aliases + +### Bash + +If you use your own aliases, SCM Breeze will **not** set up bash tab completion +for your aliases. You will need to set that up yourself. + + +### Zsh + +You just need to set the option: `setopt no_complete_aliases` (oh-my-zsh sets +this by default). Zsh will then expand aliases like `gb` to `git branch`, and +use the completion for that. + + +## Updating + +Please run `update_scm_breeze` to fetch the latest code. This will update SCM +Breeze from Github, and will create or patch your `~/.*.scmbrc` config files if +any new settings are added. + + +## Uninstalling ```bash ~/.scm_breeze/uninstall.sh ``` -The uninstall script removes the following line from your `.bashrc` or `.zshrc`: +The uninstall script removes the following line from your `.bashrc` or +`.zshrc`: `[ -s "$HOME/.scm_breeze/scm_breeze.sh" ] && source "$HOME/.scm_breeze/scm_breeze.sh"` -# Configuration -SCM Breeze is configured via automatically installed `~/.*.scmbrc` files. -To change git configuration, edit `~/.git.scmbrc`. +## Contributing -Each feature is modular, so you are free to ignore the parts you don't want to use. -Just comment out the relevant line in `~/.scm_breeze/scm_breeze.sh`. - -**Note:** After changing any settings, you will need to run `source ~/.bashrc` (or `source ~/.zshrc`) - -I know we grow attached to the aliases we use every day, so I've made the alias system completely customizable. -You have two options when it comes to aliases: - -### 1) Configure and use the provided SCM Breeze aliases - -Just tweak the aliases in `~/.git.scmbrc`. You can also change or remove any keyboard shortcuts. -These aliases also come with tab completion. For example, you can type `gco ` to tab complete your list of branches. - -### 2) Use your own aliases - -In your `git.scmbrc` config file, just set the `git_setup_aliases` option to `no`. -Your existing git aliases will then be used, and you will still be able to use the numeric shortcuts feature. -SCM Breeze creates a function to wrap the 'git' command, which expands numeric arguments, and uses `hub` if available. - -A few aliases will still be defined for the central SCM Breeze features, such as `gs` for the extended `git status`, -and `ga` for the `git add` function. - -If you already have an alias like `alias gco="git checkout"`, -you can now type `gco 1` to checkout the first file in the output of SCM Breeze's `git status`. - -# Notes about Tab Completion for Aliases - -### Bash - -If you use your own aliases, SCM Breeze will **not** set up bash tab completion for your aliases. -You will need to set that up yourself. - -### Zsh - -You just need to set the option: `setopt no_complete_aliases` (oh-my-zsh sets this by default). -Zsh will then expand aliases like `gb` to `git branch`, and use the completion for that. - -# Contributing - -SCM Breeze lives on Github at [https://github.com/ndbroadbent/scm_breeze](https://github.com/ndbroadbent/scm_breeze) - -Please feel free to fork and send pull requests, especially if you would like to build these features -for Mercurial, SVN, etc. +SCM Breeze lives on Github at +[`scmbreeze/scm_breeze`](https://github.com/scmbreeze/scm_breeze) +If you have any awesome SCM scripts lurking in your `.bashrc` or `.zshrc`, +please feel free to send me a pull request. It would be cool to make this +project into an [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) for +SCMs. ***Enjoy!*** From 6d0637ba672e58ecb5d511197e0a627a817f95b8 Mon Sep 17 00:00:00 2001 From: Martino Visintin Date: Fri, 27 Jan 2017 21:05:00 +0000 Subject: [PATCH 61/84] prune subsections from TOC --- README.markdown | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.markdown b/README.markdown index ca83466..28e9643 100644 --- a/README.markdown +++ b/README.markdown @@ -19,23 +19,13 @@ features. - [Installation](#installation) - [Usage](#usage) - [File Shortcuts](#file-shortcuts) - - [Git Status Shortcuts:](#git-status-shortcuts) - - ['ls' shortcuts:](#ls-shortcuts) - - [Other shortcuts](#other-shortcuts) - [Keyboard bindings](#keyboard-bindings) - [Repository Index](#repository-index) - [Linking External Project Design Directories](#linking-external-project-design-directories) - - [1) Create and configure a root design directory](#1-create-and-configure-a-root-design-directory) - - [2) Initialize design directories for your projects](#2-initialize-design-directories-for-your-projects) - - [3) Link existing design directories into your projects](#3-link-existing-design-directories-into-your-projects) - [Configuration](#configuration) - - [1) Configure and use the provided SCM Breeze aliases](#1-configure-and-use-the-provided-scm-breeze-aliases) - - [2) Use your own aliases](#2-use-your-own-aliases) - [Updating](#updating) - [Uninstalling](#uninstalling) - [Notes about Tab Completion for Aliases](#notes-about-tab-completion-for-aliases) - - [Bash](#bash) - - [Zsh](#zsh) - [Contributing](#contributing) From 4d4736d406f9e0e9b1c28a5c3b2c728a39a51bd9 Mon Sep 17 00:00:00 2001 From: Martino Visintin Date: Fri, 27 Jan 2017 21:22:43 +0000 Subject: [PATCH 62/84] remove unimplemented scms --- lib/bzr/BUILDME | 0 lib/hg/BUILDME | 0 lib/svn/BUILDME | 0 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 lib/bzr/BUILDME delete mode 100644 lib/hg/BUILDME delete mode 100644 lib/svn/BUILDME diff --git a/lib/bzr/BUILDME b/lib/bzr/BUILDME deleted file mode 100644 index e69de29..0000000 diff --git a/lib/hg/BUILDME b/lib/hg/BUILDME deleted file mode 100644 index e69de29..0000000 diff --git a/lib/svn/BUILDME b/lib/svn/BUILDME deleted file mode 100644 index e69de29..0000000 From 455239f59406ca39ab731812867a23b23001b218 Mon Sep 17 00:00:00 2001 From: Martino Visintin Date: Fri, 27 Jan 2017 21:41:50 +0000 Subject: [PATCH 63/84] make tests independent of bin locations On my system (Arch Linux), the commands {mv,rm,sed} live under `/usr/bin`, not under `/bin`. So the tests were failing. This commit hard-codes the initial paths to make the tests independent on their real paths. --- test/lib/git/shell_shortcuts_test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index b826a0b..76d23fd 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -33,9 +33,9 @@ oneTimeSetUp() { # Test functions function ln() { ln $@; } # Test aliases - alias mv="nocorrect mv" - alias rm="rm --option" - alias sed="sed" + alias mv="nocorrect /bin/mv" + alias rm="/bin/rm --option" + alias sed="/bin/sed" # Test already wrapped commands alias cat="exec_scmb_expand_args /bin/cat" From 31f561a99135e786c52346936ab6a5481fefde9c Mon Sep 17 00:00:00 2001 From: chrisfinazzo Date: Mon, 30 Jan 2017 20:51:25 -0500 Subject: [PATCH 64/84] Fix Shellcheck error --- uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.sh b/uninstall.sh index ca7b83a..107cdf0 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -3,5 +3,5 @@ # Remove line from bashrc and zshrc if present. for rc in bashrc zshrc; do sed -i '/scm_breeze/d' "$HOME/.$rc" - printf "== Removed SCM Breeze from '$HOME/.$rc'\n" + printf "Removed SCM Breeze from '$HOME/.$rc''%s\n" done From e95b9a33a108642a5c01ca070963fc53a6dfaf07 Mon Sep 17 00:00:00 2001 From: Wilhelmina Drengwitz Date: Tue, 31 Jan 2017 15:42:21 -0500 Subject: [PATCH 65/84] Fix printf usage --- uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.sh b/uninstall.sh index 107cdf0..0805a6e 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -3,5 +3,5 @@ # Remove line from bashrc and zshrc if present. for rc in bashrc zshrc; do sed -i '/scm_breeze/d' "$HOME/.$rc" - printf "Removed SCM Breeze from '$HOME/.$rc''%s\n" + printf "Removed SCM Breeze from %s\n" "$HOME/.$rc" done From 6f4babeced9b283b3a2d842cbb967d0ca4a0af24 Mon Sep 17 00:00:00 2001 From: Wilhelmina Drengwitz Date: Tue, 31 Jan 2017 15:50:14 -0500 Subject: [PATCH 66/84] Extend tests to use conditional exe paths --- test/lib/git/shell_shortcuts_test.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 76d23fd..522b586 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -33,11 +33,11 @@ oneTimeSetUp() { # Test functions function ln() { ln $@; } # Test aliases - alias mv="nocorrect /bin/mv" - alias rm="/bin/rm --option" - alias sed="/bin/sed" + alias mv="nocorrect $(which mv)" + alias rm="$(which rm) --option" + alias sed="$(which sed)" # Test already wrapped commands - alias cat="exec_scmb_expand_args /bin/cat" + alias cat="exec_scmb_expand_args $(which cat)" # Run shortcut wrapping source "$scmbDir/lib/git/shell_shortcuts.sh" @@ -59,11 +59,11 @@ assertAliasEquals(){ #----------------------------------------------------------------------------- test_shell_command_wrapping() { - assertAliasEquals "exec_scmb_expand_args /bin/rm --option" "rm" - assertAliasEquals "exec_scmb_expand_args nocorrect /bin/mv" "mv" - assertAliasEquals "exec_scmb_expand_args /bin/sed" "sed" - assertAliasEquals "exec_scmb_expand_args /bin/cat" "cat" - assertAliasEquals "exec_scmb_expand_args builtin cd" "cd" + assertAliasEquals "exec_scmb_expand_args $(which rm) --option" "rm" + assertAliasEquals "exec_scmb_expand_args nocorrect $(which mv)" "mv" + assertAliasEquals "exec_scmb_expand_args $(which sed)" "sed" + assertAliasEquals "exec_scmb_expand_args $(which cat)" "cat" + assertAliasEquals "exec_scmb_expand_args builtin cd" "cd" assertIncludes "$(declare -f ln)" "ln ()" assertIncludes "$(declare -f ln)" "exec_scmb_expand_args __original_ln" } From 39f659686146eb7882af2f48b9ac76ffbee0ad27 Mon Sep 17 00:00:00 2001 From: Martino Visintin Date: Sun, 12 Feb 2017 20:43:00 +0000 Subject: [PATCH 67/84] fix bin path testing --- test/lib/git/shell_shortcuts_test.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 522b586..b4664f3 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -33,11 +33,15 @@ oneTimeSetUp() { # Test functions function ln() { ln $@; } # Test aliases - alias mv="nocorrect $(which mv)" - alias rm="$(which rm) --option" - alias sed="$(which sed)" + export mv_path="$(which mv)" + export rm_path="$(which rm)" + export sed_path="$(which sed)" + export cat_pathj="$(which cat)" + alias mv="nocorrect $mv_path" + alias rm="$rm_path --option" + alias sed="$sed_path" # Test already wrapped commands - alias cat="exec_scmb_expand_args $(which cat)" + alias cat="exec_scmb_expand_args $cat_path" # Run shortcut wrapping source "$scmbDir/lib/git/shell_shortcuts.sh" @@ -59,10 +63,10 @@ assertAliasEquals(){ #----------------------------------------------------------------------------- test_shell_command_wrapping() { - assertAliasEquals "exec_scmb_expand_args $(which rm) --option" "rm" - assertAliasEquals "exec_scmb_expand_args nocorrect $(which mv)" "mv" - assertAliasEquals "exec_scmb_expand_args $(which sed)" "sed" - assertAliasEquals "exec_scmb_expand_args $(which cat)" "cat" + assertAliasEquals "exec_scmb_expand_args $rm_path --option" "rm" + assertAliasEquals "exec_scmb_expand_args nocorrect $mv_path" "mv" + assertAliasEquals "exec_scmb_expand_args $sed_path" "sed" + assertAliasEquals "exec_scmb_expand_args $cat_path" "cat" assertAliasEquals "exec_scmb_expand_args builtin cd" "cd" assertIncludes "$(declare -f ln)" "ln ()" assertIncludes "$(declare -f ln)" "exec_scmb_expand_args __original_ln" From 67458229530e66b0223ffeb99e55e3a44c64b77f Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sun, 19 Feb 2017 20:05:59 +0700 Subject: [PATCH 68/84] Fix IFS issues - have to always unset after use --- lib/design.sh | 1 + lib/git/branch_shortcuts.sh | 1 + lib/git/fallback/status_shortcuts_shell.sh | 2 +- lib/git/repo_index.sh | 12 ++++++------ lib/git/shell_shortcuts.sh | 8 ++++---- lib/git/status_shortcuts.sh | 6 +++--- test/lib/git/repo_index_test.sh | 4 ++-- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/design.sh b/lib/design.sh index 5106247..e0e2091 100644 --- a/lib/design.sh +++ b/lib/design.sh @@ -102,5 +102,6 @@ design() { printf "Invalid command.\n\n" design fi + unset IFS } diff --git a/lib/git/branch_shortcuts.sh b/lib/git/branch_shortcuts.sh index ddea8dc..61012e2 100644 --- a/lib/git/branch_shortcuts.sh +++ b/lib/git/branch_shortcuts.sh @@ -39,6 +39,7 @@ EOF if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi let e++ done + unset IFS } __git_alias "$git_branch_alias" "_scmb_git_branch_shortcuts" "" diff --git a/lib/git/fallback/status_shortcuts_shell.sh b/lib/git/fallback/status_shortcuts_shell.sh index e7cce4b..9368588 100755 --- a/lib/git/fallback/status_shortcuts_shell.sh +++ b/lib/git/fallback/status_shortcuts_shell.sh @@ -114,7 +114,7 @@ git_status_shortcuts() { # so just use plain 'git status' git status fi - IFS=$' \t\n' + unset IFS zsh_reset # Reset zsh environment to default } # Template function for 'git_status_shortcuts'. diff --git a/lib/git/repo_index.sh b/lib/git/repo_index.sh index c77d115..b197d49 100644 --- a/lib/git/repo_index.sh +++ b/lib/git/repo_index.sh @@ -116,7 +116,7 @@ function git_index() { fi fi fi - IFS=$' \t\n' + unset IFS } _git_index_dirs_without_home() { @@ -131,7 +131,7 @@ function _find_git_repos() { echo ${repo%/.git} # Return project folder, with trailing ':' _find_git_submodules $repo # Detect any submodules done - IFS=$' \t\n' + unset IFS } # List all submodules for a git repo, if any. @@ -150,7 +150,7 @@ function _rebuild_git_index() { for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do echo $(basename $repo | sed "s/ /_/g") $repo done | sort | cut -d " " -f2- >| "$GIT_REPO_DIR/.git_index" - IFS=$' \t\n' + unset IFS if [ "$1" != "--silent" ]; then echo -e "===== Indexed $_bld_col$(_git_index_count)$_txt_col repos in $GIT_REPO_DIR/.git_index" @@ -225,7 +225,7 @@ _git_index_update_all_branches() { echo "=== Skipping $branch: remote and merge refs are not configured." fi done - IFS=$' \t\n' + unset IFS # Update all remotes if there are any branches to update if [ -n "${branches[*]}" ]; then git fetch --all 2> /dev/null; fi @@ -268,7 +268,7 @@ function _git_index_batch_cmd() { cwd="$PWD" if [ -n "$1" ]; then echo -e "== Running command for $_bld_col$(_git_index_count)$_txt_col repos...\n" - IFS=$' \t\n' + unset IFS local base_path for base_path in $(sed -e "s/--.*//" "$GIT_REPO_DIR/.git_index" | \grep . | sort); do builtin cd "$base_path" @@ -313,7 +313,7 @@ if [ $shell = 'bash' ]; then else COMPREPLY=($(compgen -W '$(sed -e "s:.*/::" -e "s:$:/:" "$GIT_REPO_DIR/.git_index" | sort)' -- $curw)) fi - IFS=$' \t\n' + unset IFS return 0 } else diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 26a9ff4..6299537 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -125,11 +125,11 @@ if [ "$shell_ls_aliases_enabled" = "true" ] && which ruby > /dev/null 2>&1; then fi # Parse path from args - OLDIFS="$IFS"; IFS=$'\n' + IFS=$'\n' for arg in $@; do if [ -d "$arg" ]; then local rel_path="${arg%/}"; fi done - IFS="$OLDIFS" + unset IFS # Replace user/group with user symbol, if defined at ~/.user_sym # Before : -rw-rw-r-- 1 ndbroadbent ndbroadbent 1.1K Sep 19 21:39 scm_breeze.sh @@ -175,14 +175,14 @@ EOF ll_files="$(\ls "$@")" fi - OLDIFS="$IFS"; IFS=$'\n' + IFS=$'\n' for file in $ll_files; do if [ -n "$rel_path" ]; then file="$rel_path/$file"; fi export $git_env_char$e="$(eval $_abs_path_command \"${file//\"/\\\"}\")" if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi let e++ done - IFS="$OLDIFS" + unset IFS # Turn off shwordsplit unless it was on previously if [[ $shell == "zsh" ]] && [ -z "$SHWORDSPLIT_ON" ]; then unsetopt shwordsplit; fi diff --git a/lib/git/status_shortcuts.sh b/lib/git/status_shortcuts.sh index a2e20e4..d63bb0c 100644 --- a/lib/git/status_shortcuts.sh +++ b/lib/git/status_shortcuts.sh @@ -43,7 +43,7 @@ git_status_shortcuts() { if [ "${scmbDebug:-}" = "true" ]; then echo "Set \$$git_env_char$e => $file"; fi let e++ done - IFS=$' \t\n' + unset IFS if [ "${scmbDebug:-}" = "true" ]; then echo "------------------------"; fi # Print status @@ -91,7 +91,7 @@ git_silent_add_shortcuts() { echo -e "# Added '$file'" fi done - IFS=$' \t\n' + unset IFS echo "#" fi } @@ -186,7 +186,7 @@ _git_resolve_merge_conflict() { git add "$file" echo -e "# Added $1 version of '$file'" done - IFS=$' \t\n' + unset IFS echo -e "# -- If you have finished resolving conflicts, commit the resolutions with 'git commit'" fi } diff --git a/test/lib/git/repo_index_test.sh b/test/lib/git/repo_index_test.sh index d2afa8e..f7006ed 100755 --- a/test/lib/git/repo_index_test.sh +++ b/test/lib/git/repo_index_test.sh @@ -63,7 +63,7 @@ EOF for dir in $GIT_REPOS; do mkdir -p $dir; cd $dir; git init; done - IFS=$' \t\n' + unset IFS verboseGitCommands @@ -74,7 +74,7 @@ oneTimeTearDown() { rm -rf "${GIT_REPO_DIR}" IFS=":" for dir in $GIT_REPOS; do rm -rf $dir; done - IFS=$' \t\n' + unset IFS } ensureIndex() { From cd6f7d8640222b78655577d523a9090dbd42c21f Mon Sep 17 00:00:00 2001 From: Benjamin Polge Date: Fri, 29 Jul 2016 15:47:52 -0400 Subject: [PATCH 69/84] plugin-ified scm_breeze --- scm_breeze.plugin.zsh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 scm_breeze.plugin.zsh diff --git a/scm_breeze.plugin.zsh b/scm_breeze.plugin.zsh new file mode 100644 index 0000000..dbd6a0a --- /dev/null +++ b/scm_breeze.plugin.zsh @@ -0,0 +1,25 @@ +######################################################### +# Forked from http://github.com/ndbroadbent/scm_breeze # +# # +# File Copied and modified from ./install.sh # +# to be compatible with oh-my-zsh's plugin system # +######################################################### + +#!/bin/bash +#locate the dir where this script is stored +export scmbDir="$( cd -P "$( dirname "$0" )" && pwd )" + +# Symlink to ~/.scm_breeze if installing from another path +if [ ! -s "$HOME/.scm_breeze" ] && [ "$scmbDir" != "$HOME/.scm_breeze" ]; then + ln -fs "$scmbDir" "$HOME/.scm_breeze" + + # Load SCM Breeze update scripts + source "$scmbDir/lib/scm_breeze.sh" + # Create '~/.*.scmbrc' files from example files + _create_or_patch_scmbrc +fi + +# This loads SCM Breeze into the shell session. +[ -s "$HOME/.scm_breeze/scm_breeze.sh" ] && source "$HOME/.scm_breeze/scm_breeze.sh" + + From 65df76ebe4b3e587924b172c1cf9713732973d17 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Sat, 6 May 2017 23:13:45 +0700 Subject: [PATCH 70/84] Fixed key binding --- lib/git/keybindings.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git/keybindings.sh b/lib/git/keybindings.sh index 4ea46c3..8ec4066 100644 --- a/lib/git/keybindings.sh +++ b/lib/git/keybindings.sh @@ -32,8 +32,8 @@ if [[ "$git_keyboard_shortcuts_enabled" = "true" ]]; then _bind "$git_commit_all_with_ci_skip_keys" " \033[1~ APPEND='[ci skip]' git_commit_all ""\n" else _bind "$git_commit_all_keys" "\" git_commit_all\n\"" - _bind "$git_add_and_commit_keys" "\"\033[1~ git_add_and_commit \n\"" - _bind "$git_commit_all_with_ci_skip_keys" "\"\033[1~ APPEND='[ci skip]' git_commit_all \n\"" + _bind "$git_add_and_commit_keys" "\"\C-A git_add_and_commit \n\"" + _bind "$git_commit_all_with_ci_skip_keys" "\"\C-A APPEND='[ci skip]' git_commit_all \n\"" fi fi From 2ef2fdc77a96dc97d2f5ed0d60e31ef882a64659 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Mon, 25 Sep 2017 17:53:40 +0700 Subject: [PATCH 71/84] Remove maintainer message, made a little logo --- README.markdown | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 28e9643..02f7523 100644 --- a/README.markdown +++ b/README.markdown @@ -1,8 +1,4 @@ -# Now looking for help with maintainance. - -## Please post an issue if you would like to help out. - ---- + # SCM Breeze [![TravisCI](https://secure.travis-ci.org/scmbreeze/scm_breeze.png?branch=master)](http://travis-ci.org/scmbreeze/scm_breeze) From a59ace0f297402031d3a47b1b59f9bf8c776a822 Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Tue, 26 Sep 2017 02:47:48 +0700 Subject: [PATCH 72/84] Changed logo --- README.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 02f7523..936281e 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,6 @@ - + + + # SCM Breeze [![TravisCI](https://secure.travis-ci.org/scmbreeze/scm_breeze.png?branch=master)](http://travis-ci.org/scmbreeze/scm_breeze) From ca5c15d4a0ee881fa8bc2b1923146adb93933b0c Mon Sep 17 00:00:00 2001 From: Nicolas Quiniou-Briand Date: Wed, 27 Jun 2018 08:44:57 -0400 Subject: [PATCH 73/84] replace 'ge' by `ge` --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 936281e..8843857 100644 --- a/README.markdown +++ b/README.markdown @@ -114,7 +114,7 @@ $ gco 5 You can use these shortcuts with system commands by passing your command -through `exec_scmb_expand_args` (default alias is 'ge'): +through `exec_scmb_expand_args` (default alias is `ge`): ```bash From 1f3b8a6b11ab1d60cdbdea56525b4aefee8326a5 Mon Sep 17 00:00:00 2001 From: Michael Mior Date: Fri, 13 Apr 2018 08:49:22 -0400 Subject: [PATCH 74/84] Use ^M instead of for newlines --- lib/git/keybindings.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/git/keybindings.sh b/lib/git/keybindings.sh index 8ec4066..11bb698 100644 --- a/lib/git/keybindings.sh +++ b/lib/git/keybindings.sh @@ -27,13 +27,13 @@ if [[ "$git_keyboard_shortcuts_enabled" = "true" ]]; then # Uses emacs style keybindings, so vi mode is not supported for now if ! set -o | grep -q '^vi .*on$'; then if [[ $shell == "zsh" ]]; then - _bind "$git_commit_all_keys" " git_commit_all""\n" - _bind "$git_add_and_commit_keys" " \033[1~ git_add_and_commit ""\n" - _bind "$git_commit_all_with_ci_skip_keys" " \033[1~ APPEND='[ci skip]' git_commit_all ""\n" + _bind "$git_commit_all_keys" " git_commit_all""^M" + _bind "$git_add_and_commit_keys" " \033[1~ git_add_and_commit ""^M" + _bind "$git_commit_all_with_ci_skip_keys" " \033[1~ APPEND='[ci skip]' git_commit_all ""^M" else - _bind "$git_commit_all_keys" "\" git_commit_all\n\"" - _bind "$git_add_and_commit_keys" "\"\C-A git_add_and_commit \n\"" - _bind "$git_commit_all_with_ci_skip_keys" "\"\C-A APPEND='[ci skip]' git_commit_all \n\"" + _bind "$git_commit_all_keys" "\" git_commit_all^M\"" + _bind "$git_add_and_commit_keys" "\"\C-A git_add_and_commit ^M\"" + _bind "$git_commit_all_with_ci_skip_keys" "\"\C-A APPEND='[ci skip]' git_commit_all ^M\"" fi fi From 77b1717008594e6a55fabb04ff4fcce7cbbc055f Mon Sep 17 00:00:00 2001 From: "Tom \"Ravi\" Hale" Date: Fri, 17 Aug 2018 12:49:07 +0700 Subject: [PATCH 75/84] Avoid test with no arguments and unnecessary subshell --- lib/git/shell_shortcuts.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git/shell_shortcuts.sh b/lib/git/shell_shortcuts.sh index 6299537..4c427d8 100644 --- a/lib/git/shell_shortcuts.sh +++ b/lib/git/shell_shortcuts.sh @@ -5,9 +5,9 @@ # ------------------------------------------------------------------------------ -if test | sed -E 's///g' 2>/dev/null; then +if sed -E 's///g' /dev/null; then SED_REGEX_ARG="E" -elif test | sed -r 's///g' 2>/dev/null; then +elif sed -r 's///g' /dev/null; then SED_REGEX_ARG="r" else echo "Cannot determine extended regex argument for sed! (Doesn't respond to either -E or -r)" From 70b4e62bb04f3de8cb4f75793b9c4b1c48c6eb37 Mon Sep 17 00:00:00 2001 From: "Tom \"Ravi\" Hale" Date: Sat, 18 Aug 2018 14:35:43 +0700 Subject: [PATCH 76/84] Remove -- from end of aliases --- lib/git/aliases.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 4cbdaed..9632c79 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -100,15 +100,15 @@ if [ "$git_setup_aliases" = "yes" ]; then __git_alias "$git_checkout_alias" 'git' 'checkout' __git_alias "$git_commit_alias" 'git' 'commit' __git_alias "$git_commit_verbose_alias" 'git' 'commit' '--verbose' - __git_alias "$git_reset_alias" 'git' 'reset' '--' + __git_alias "$git_reset_alias" 'git' 'reset' __git_alias "$git_reset_hard_alias" 'git' 'reset' '--hard' __git_alias "$git_rm_alias" 'git' 'rm' __git_alias "$git_blame_alias" 'git' 'blame' - __git_alias "$git_diff_no_whitespace_alias" 'git' 'diff' '-w' '--' + __git_alias "$git_diff_no_whitespace_alias" 'git' 'diff' '-w' __git_alias "$git_diff_alias" 'git' 'diff' - __git_alias "$git_diff_file_alias" 'git' 'diff' '--' + __git_alias "$git_diff_file_alias" 'git' 'diff' __git_alias "$git_diff_word_alias" 'git' 'diff' '--word-diff' - __git_alias "$git_diff_cached_alias" 'git' 'diff' '--cached --' + __git_alias "$git_diff_cached_alias" 'git' 'diff' '--cached' __git_alias "$git_add_patch_alias" 'git' 'add' '-p' __git_alias "$git_add_updated_alias" 'git' 'add' '-u' __git_alias "$git_difftool_alias" 'git' 'difftool' From 92689b3a19d247f03b3e0229e44e3ec2d3835951 Mon Sep 17 00:00:00 2001 From: Wilhelmina Drengwitz Date: Fri, 31 Aug 2018 07:13:23 -0400 Subject: [PATCH 77/84] Add links to alternatives --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 8843857..07abd94 100644 --- a/README.markdown +++ b/README.markdown @@ -406,3 +406,7 @@ SCMs. ***Enjoy!*** +## Alternative Projects + +1. https://github.com/shinriyo/breeze `fish` support +1. https://github.com/mroth/scmpuff static go binary From 744cae46d6f259d2076218df34a4f9648141ce69 Mon Sep 17 00:00:00 2001 From: Willa Drengwitz Date: Fri, 31 Aug 2018 07:29:44 -0400 Subject: [PATCH 78/84] Fix uninstall for osx --- uninstall.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index 0805a6e..f91235a 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,7 +1,15 @@ #!/bin/sh # uninstall by (github: bernardofire) # Remove line from bashrc and zshrc if present. + +sed="sed -i" +if [[ $OSTYPE == "Darwin" ]]; then + sed="sed -i ''" +fi + for rc in bashrc zshrc; do - sed -i '/scm_breeze/d' "$HOME/.$rc" - printf "Removed SCM Breeze from %s\n" "$HOME/.$rc" + if [ -f "$HOME/.$rc" ]; then + $sed '/scm_breeze/d' "$HOME/.$rc" && + printf "Removed SCM Breeze from %s\n" "$HOME/.$rc" + fi done From a3ff809cbebb593fc115e240b0c942653a302d12 Mon Sep 17 00:00:00 2001 From: Willa Drengwitz Date: Fri, 31 Aug 2018 07:56:58 -0400 Subject: [PATCH 79/84] Fix ordering to match declare order --- test/lib/git/shell_shortcuts_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 37281d4..8bae83e 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -67,8 +67,8 @@ assertAliasEquals(){ #----------------------------------------------------------------------------- test_shell_command_wrapping() { - assertAliasEquals "exec_scmb_expand_args $rm_path --option" "rm" assertAliasEquals "exec_scmb_expand_args nocorrect $mv_path" "mv" + assertAliasEquals "exec_scmb_expand_args $rm_path --option" "rm" assertAliasEquals "exec_scmb_expand_args $sed_path" "sed" assertAliasEquals "exec_scmb_expand_args $cat_path" "cat" assertAliasEquals "exec_scmb_expand_args builtin cd" "cd" From d0c832913758ff7722b4975b9629e27b4f3ce74b Mon Sep 17 00:00:00 2001 From: Willa Drengwitz Date: Fri, 31 Aug 2018 08:58:23 -0400 Subject: [PATCH 80/84] Fix sorting order --- lib/git/repo_index.sh | 8 ++++---- test/lib/git/repo_index_test.sh | 25 ++++++++++++++----------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/git/repo_index.sh b/lib/git/repo_index.sh index b197d49..3d2e9c7 100644 --- a/lib/git/repo_index.sh +++ b/lib/git/repo_index.sh @@ -68,8 +68,8 @@ function git_index() { elif [ "$1" = "--list" ] || [ "$1" = "-l" ]; then echo -e "$_bld_col$(_git_index_count)$_txt_col Git repositories in $_bld_col$GIT_REPO_DIR$_txt_col:\n" for repo in $(_git_index_dirs_without_home); do - echo $(basename $repo) : $repo - done | sort | column -t -s ':' + echo $(basename $repo | sed "s/ /_/g") : $repo + done | sort -t ":" -k1,1 | column -t -s ':' elif [ "$1" = "--count-by-host" ]; then echo -e "=== Producing a report of the number of repos per host...\n" _git_index_batch_cmd git remote -v | \grep "origin.*(fetch)" | @@ -148,8 +148,8 @@ function _rebuild_git_index() { # Get repos from src dir and custom dirs, then sort by basename IFS=$'\n' for repo in $(echo -e "$(_find_git_repos)\n$(echo $GIT_REPOS | sed "s/:/\\\\n/g")"); do - echo $(basename $repo | sed "s/ /_/g") $repo - done | sort | cut -d " " -f2- >| "$GIT_REPO_DIR/.git_index" + echo $(basename $repo | sed "s/ /_/g"):$repo + done | sort -t ":" -k1,1 | cut -d ":" -f2- >| "$GIT_REPO_DIR/.git_index" unset IFS if [ "$1" != "--silent" ]; then diff --git a/test/lib/git/repo_index_test.sh b/test/lib/git/repo_index_test.sh index f7006ed..c2d2571 100755 --- a/test/lib/git/repo_index_test.sh +++ b/test/lib/git/repo_index_test.sh @@ -94,16 +94,19 @@ test_repo_index_command() { git_index --rebuild > /dev/null # Test that all repos are detected, and sorted alphabetically - assertIncludes "$(index_no_newlines)" "bitbucket.*\ -blue_submodule.*\ -github.*\ -green_submodule.*\ -red_submodule.*\ -source_forge.*\ -submodules_everywhere.*\ -test_repo_11.*\ -test_repo_1" - + assertIncludes "$(index_no_newlines)" $( + cat < Date: Fri, 31 Aug 2018 08:58:41 -0400 Subject: [PATCH 81/84] Run `shfmt` --- test/lib/git/repo_index_test.sh | 70 ++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/test/lib/git/repo_index_test.sh b/test/lib/git/repo_index_test.sh index c2d2571..40879cd 100755 --- a/test/lib/git/repo_index_test.sh +++ b/test/lib/git/repo_index_test.sh @@ -7,10 +7,14 @@ # # Unit tests for git shell scripts -export scmbDir="$( cd -P "$( dirname "$0" )" && pwd )/../../.." +export scmbDir="$(cd -P "$(dirname "$0")" && pwd)/../../.." # Zsh compatibility -if [ -n "${ZSH_VERSION:-}" ]; then shell="zsh"; SHUNIT_PARENT=$0; setopt shwordsplit; fi +if [ -n "${ZSH_VERSION:-}" ]; then + shell="zsh" + SHUNIT_PARENT=$0 + setopt shwordsplit +fi # Load test helpers source "$scmbDir/test/support/test_helper.sh" @@ -19,7 +23,6 @@ source "$scmbDir/test/support/test_helper.sh" source "$scmbDir/lib/scm_breeze.sh" source "$scmbDir/lib/git/repo_index.sh" - # Setup and tear down #----------------------------------------------------------------------------- oneTimeSetUp() { @@ -34,7 +37,10 @@ oneTimeSetUp() { cd $GIT_REPO_DIR # Setup test repos in temp repo dir for repo in github bitbucket source_forge TestCaps; do - mkdir $repo; cd $repo; git init; cd - > /dev/null + mkdir $repo + cd $repo + git init + cd - >/dev/null done # Add some nested dirs for testing resursive tab completion @@ -47,7 +53,7 @@ oneTimeSetUp() { mkdir submodules_everywhere cd submodules_everywhere git init - cat > .gitmodules <.gitmodules < /dev/null + mkdir $repo + cd $repo + git init + cd - >/dev/null done # Setup some custom repos outside the main repo dir IFS=":" for dir in $GIT_REPOS; do - mkdir -p $dir; cd $dir; git init; + mkdir -p $dir + cd $dir + git init done unset IFS @@ -85,13 +96,12 @@ index_no_newlines() { tr "\\n" " " < $git_index_file } - #----------------------------------------------------------------------------- # Unit tests #----------------------------------------------------------------------------- test_repo_index_command() { - git_index --rebuild > /dev/null + git_index --rebuild >/dev/null # Test that all repos are detected, and sorted alphabetically assertIncludes "$(index_no_newlines)" $( @@ -111,7 +121,7 @@ EXPECT test_check_git_index() { ensureIndex - echo "should not be regenerated" >> $git_index_file + echo "should not be regenerated" >>$git_index_file _check_git_index # Test that index is not rebuilt unless empty assertIncludes "$(index_no_newlines)" "should not be regenerated" @@ -128,7 +138,7 @@ test_git_index_count() { test_repo_list() { ensureIndex list=$(git_index --list) - assertIncludes "$list" "bitbucket" || return + assertIncludes "$list" "bitbucket" || return assertIncludes "$list" "blue_submodule" || return assertIncludes "$list" "test_repo_11" } @@ -136,16 +146,26 @@ test_repo_list() { # Test matching rules for changing directory test_git_index_changing_directory() { ensureIndex - git_index "github"; assertEquals "$GIT_REPO_DIR/github" "$PWD" - git_index "github/"; assertEquals "$GIT_REPO_DIR/github" "$PWD" - git_index "bucket"; assertEquals "$GIT_REPO_DIR/bitbucket" "$PWD" - git_index "testcaps"; assertEquals "$GIT_REPO_DIR/TestCaps" "$PWD" - git_index "green_sub"; assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/green_submodule" "$PWD" - git_index "_submod"; assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/blue_submodule" "$PWD" - git_index "test_repo_1"; assertEquals "/tmp/test_repo_1" "$PWD" - git_index "test_repo_11"; assertEquals "/tmp/test_repo_11" "$PWD" - git_index "test_repo_"; assertEquals "/tmp/test_repo_1" "$PWD" - git_index "github/videos/octocat/live_action"; assertEquals "$GIT_REPO_DIR/github/videos/octocat/live_action" "$PWD" + git_index "github" + assertEquals "$GIT_REPO_DIR/github" "$PWD" + git_index "github/" + assertEquals "$GIT_REPO_DIR/github" "$PWD" + git_index "bucket" + assertEquals "$GIT_REPO_DIR/bitbucket" "$PWD" + git_index "testcaps" + assertEquals "$GIT_REPO_DIR/TestCaps" "$PWD" + git_index "green_sub" + assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/green_submodule" "$PWD" + git_index "_submod" + assertEquals "$GIT_REPO_DIR/submodules_everywhere/very/nested/directory/blue_submodule" "$PWD" + git_index "test_repo_1" + assertEquals "/tmp/test_repo_1" "$PWD" + git_index "test_repo_11" + assertEquals "/tmp/test_repo_11" "$PWD" + git_index "test_repo_" + assertEquals "/tmp/test_repo_1" "$PWD" + git_index "github/videos/octocat/live_action" + assertEquals "$GIT_REPO_DIR/github/videos/octocat/live_action" "$PWD" } test_git_index_tab_completion() { @@ -166,16 +186,15 @@ test_git_index_tab_completion() { # Test completion for project sub-directories when project ends with '/' COMP_WORDS="github/" _git_index_tab_completion - assertIncludes "$(tab_completions)" "github/videos/" + assertIncludes "$(tab_completions)" "github/videos/" # Check that '.git/' is filtered from completion, but other hidden dirs are available assertNotIncludes "$(tab_completions)" "github/.git/" - assertIncludes "$(tab_completions)" "github/.im_hidden/" + assertIncludes "$(tab_completions)" "github/.im_hidden/" COMP_WORDS="github/videos/" _git_index_tab_completion assertIncludes "$(tab_completions)" "github/videos/octocat/" - # Test that completion checks for other matching projects even if one matches perfectly COMP_WORDS="test_repo_1" _git_index_tab_completion @@ -183,7 +202,6 @@ test_git_index_tab_completion() { fi } - # Test changing to top-level directory (when arg begins with '/') test_changing_to_top_level_directory() { mkdir "$GIT_REPO_DIR/gems" @@ -191,8 +209,6 @@ test_changing_to_top_level_directory() { assertEquals "$GIT_REPO_DIR/gems" "$PWD" } - # load and run shUnit2 # Call this function to run tests source "$scmbDir/test/support/shunit2" - From f5850830fa5ea866ec563304e6072ee14cf9cef3 Mon Sep 17 00:00:00 2001 From: Willa Drengwitz Date: Fri, 31 Aug 2018 09:01:06 -0400 Subject: [PATCH 82/84] Fix tr illegal command --- test/lib/git/repo_index_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/git/repo_index_test.sh b/test/lib/git/repo_index_test.sh index 40879cd..c866ec4 100755 --- a/test/lib/git/repo_index_test.sh +++ b/test/lib/git/repo_index_test.sh @@ -105,7 +105,7 @@ test_repo_index_command() { # Test that all repos are detected, and sorted alphabetically assertIncludes "$(index_no_newlines)" $( - cat < Date: Tue, 7 Feb 2017 21:20:17 -0500 Subject: [PATCH 83/84] Add bash & zsh compatible way to resolve abs exe paths --- test/lib/git/shell_shortcuts_test.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/lib/git/shell_shortcuts_test.sh b/test/lib/git/shell_shortcuts_test.sh index 8bae83e..f699085 100755 --- a/test/lib/git/shell_shortcuts_test.sh +++ b/test/lib/git/shell_shortcuts_test.sh @@ -21,6 +21,13 @@ fi source "$scmbDir/test/support/test_helper.sh" source "$scmbDir/lib/scm_breeze.sh" +bin_path() { + if [ -n "${ZSH_VERSION:-}" ]; + then where "$@" | tail -1 + else which "$@" + fi +} + # Setup #----------------------------------------------------------------------------- oneTimeSetUp() { @@ -35,10 +42,10 @@ oneTimeSetUp() { # Before aliasing, get original locations so we can compare them in the test unalias mv rm sed cat 2>/dev/null - export mv_path="$(which mv)" - export rm_path="$(which rm)" - export sed_path="$(which sed)" - export cat_path="$(which cat)" + export mv_path="$(bin_path mv)" + export rm_path="$(bin_path rm)" + export sed_path="$(bin_path sed)" + export cat_path="$(bin_path cat)" # Test aliases alias mv="nocorrect $mv_path" From 7189656854b87b062e7c6d36681fef2c9fbffbde Mon Sep 17 00:00:00 2001 From: David Lee Date: Fri, 31 Aug 2018 09:32:07 -0400 Subject: [PATCH 84/84] [PATCH] Add grep_shortcuts Closes #125, Thanks David Lee! --- git.scmbrc.example | 9 ++++---- lib/git/aliases.sh | 1 + lib/git/grep_shortcuts.rb | 47 +++++++++++++++++++++++++++++++++++++++ lib/git/grep_shortcuts.sh | 24 ++++++++++++++++++++ scm_breeze.sh | 1 + 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 lib/git/grep_shortcuts.rb create mode 100644 lib/git/grep_shortcuts.sh diff --git a/git.scmbrc.example b/git.scmbrc.example index 2728b5a..2637baa 100644 --- a/git.scmbrc.example +++ b/git.scmbrc.example @@ -34,10 +34,10 @@ git_alias="g" # 1. 'SCM Breeze' functions git_status_shortcuts_alias="gs" git_add_shortcuts_alias="ga" -git_add_patch_alias="gap" -git_add_updated_alias="gau" -git_show_files_alias="gsf" exec_scmb_expand_args_alias="ge" +git_show_files_alias="gsf" +git_commit_all_alias="gca" +git_grep_shortcuts_alias="gtrep" # 2. Commands that handle paths (with shortcut args expanded) git_checkout_alias="gco" git_checkout_branch_alias="gcb" @@ -68,7 +68,8 @@ git_status_short_alias="gss" git_clean_alias="gce" git_clean_force_alias="gcef" git_add_all_alias="gaa" -git_commit_all_alias="gca" +git_add_patch_alias="gap" +git_add_updated_alias="gau" git_commit_amend_alias="gcm" git_commit_amend_no_msg_alias="gcmh" git_commit_no_msg_alias="gch" diff --git a/lib/git/aliases.sh b/lib/git/aliases.sh index 9632c79..28b0e31 100644 --- a/lib/git/aliases.sh +++ b/lib/git/aliases.sh @@ -89,6 +89,7 @@ _alias "$git_add_shortcuts_alias" 'git_add_shortcuts' _alias "$exec_scmb_expand_args_alias" 'exec_scmb_expand_args' _alias "$git_show_files_alias" 'git_show_affected_files' _alias "$git_commit_all_alias" 'git_commit_all' +_alias "$git_grep_shortcuts_alias" 'git_grep_shortcuts' # Git Index alias _alias "$git_index_alias" 'git_index' diff --git a/lib/git/grep_shortcuts.rb b/lib/git/grep_shortcuts.rb new file mode 100644 index 0000000..9f5ecc4 --- /dev/null +++ b/lib/git/grep_shortcuts.rb @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby +# encoding: UTF-8 + +PROJECT_ROOT = File.exist?(".git") ? Dir.pwd : `\git rev-parse --show-toplevel 2> /dev/null`.strip + +COLORS = { + :rst => "\033[0m", + :del => "\033[0;31m", + :mod => "\033[0;32m", + :new => "\033[0;33m", + :ren => "\033[0;34m", + :cpy => "\033[0;33m", + :typ => "\033[0;35m", + :unt => "\033[0;36m", + :dark => "\033[2;37m", + :branch => "\033[1m", + :header => "\033[0m" +} + +COLOR_MATCH = /\e\[[0-9;]*[mK]/ + +output_files = [] + +stdin = STDIN.set_encoding(Encoding::ASCII_8BIT) + +while stdin.gets + if $. > 1000 + puts "Only showing first 1000 results. Please refine your search." + break + end + print "#{COLORS[:dark]}[#{COLORS[:rst]}#{$.}#{COLORS[:dark]}]#{COLORS[:rst]} " + matches = $_.match(/(^.+?)#{COLOR_MATCH}?:#{COLOR_MATCH}?(\d+)?/) + file = matches[1] + line = matches[2] + output_files << "#{file}#{line ? ":#{line}" : ""}" + puts $_ +end + +print "@@filelist@@::" + +output_files.each_with_index {|f,i| + # If file starts with a '~', treat it as a relative path. + # This is important when dealing with symlinks + print "|" unless i == 0 + print f.start_with?("~") ? f.sub(/~/, '') : File.join(PROJECT_ROOT, f) +} +puts diff --git a/lib/git/grep_shortcuts.sh b/lib/git/grep_shortcuts.sh new file mode 100644 index 0000000..d7024ea --- /dev/null +++ b/lib/git/grep_shortcuts.sh @@ -0,0 +1,24 @@ +git_grep_shortcuts() { + fail_if_not_git_repo || return 1 + git_clear_vars + # Run ruby script, store output + tmp_grep_results="$(git rev-parse --git-dir)/tmp_grep_results_$$" + git grep -n --color=always "$@" | + /usr/bin/env ruby "$scmbDir/lib/git/grep_shortcuts.rb" >"$tmp_grep_results" + + # Fetch list of files from last line of script output + files="$(tail -1 "$tmp_grep_results" | sed 's%@@filelist@@::%%g')" + + # Export numbered env variables for each file + IFS="|" + local e=1 + for file in ${=files}; do + export $git_env_char$e="$file" + let e++ + done + IFS=$' \t\n' + + # Print status + cat "$tmp_grep_results" | sed '$d' | less -SfRMXFi + rm -f "$tmp_grep_results" +} diff --git a/scm_breeze.sh b/scm_breeze.sh index 98957d5..4d83349 100644 --- a/scm_breeze.sh +++ b/scm_breeze.sh @@ -22,6 +22,7 @@ if [[ -s "$HOME/.git.scmbrc" ]]; then source "$scmbDir/lib/git/keybindings.sh" source "$scmbDir/lib/git/status_shortcuts.sh" source "$scmbDir/lib/git/branch_shortcuts.sh" + source "$scmbDir/lib/git/grep_shortcuts.sh" source "$scmbDir/lib/git/shell_shortcuts.sh" source "$scmbDir/lib/git/repo_index.sh" source "$scmbDir/lib/git/tools.sh"