From 39eb7a003025652b2c3f991672ce84df9a44f488 Mon Sep 17 00:00:00 2001 From: Dana Sherson Date: Tue, 5 Dec 2023 00:37:10 +1300 Subject: [PATCH] Don't bash -l things --- bin/gcr | 2 +- bin/gg | 2 +- bin/{git_get => git-get} | 0 bin/{git_purge => git-purge} | 0 bin/{git_reword => git-reword} | 0 bin/git-uncommit | 3 +++ bin/{git_unstage => git-unstage} | 0 bin/git_bisect | 2 +- bin/git_bisect_branch | 4 ++-- bin/git_rebase_exec | 2 +- bin/git_uncommit | 3 --- functions/colors | 19 ++++++------------- functions/git_alias_completion.sh | 2 +- gitconfig | 6 ------ spec/git_spec.rb | 4 ++-- 15 files changed, 18 insertions(+), 31 deletions(-) rename bin/{git_get => git-get} (100%) rename bin/{git_purge => git-purge} (100%) rename bin/{git_reword => git-reword} (100%) create mode 100755 bin/git-uncommit rename bin/{git_unstage => git-unstage} (100%) mode change 100755 => 100644 delete mode 100755 bin/git_uncommit diff --git a/bin/gcr b/bin/gcr index 36e9c62..44f2a34 100755 --- a/bin/gcr +++ b/bin/gcr @@ -1,3 +1,3 @@ #!/usr/bin/env bash -git_reword $* +git reword $* diff --git a/bin/gg b/bin/gg index f3269e3..df4f93a 100755 --- a/bin/gg +++ b/bin/gg @@ -1,3 +1,3 @@ #!/usr/bin/env bash - git_get $1 +git get $1 diff --git a/bin/git_get b/bin/git-get similarity index 100% rename from bin/git_get rename to bin/git-get diff --git a/bin/git_purge b/bin/git-purge similarity index 100% rename from bin/git_purge rename to bin/git-purge diff --git a/bin/git_reword b/bin/git-reword similarity index 100% rename from bin/git_reword rename to bin/git-reword diff --git a/bin/git-uncommit b/bin/git-uncommit new file mode 100755 index 0000000..78c007c --- /dev/null +++ b/bin/git-uncommit @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echodo git reset --quiet HEAD^ diff --git a/bin/git_unstage b/bin/git-unstage old mode 100755 new mode 100644 similarity index 100% rename from bin/git_unstage rename to bin/git-unstage diff --git a/bin/git_bisect b/bin/git_bisect index cd2f4ed..fa33133 100755 --- a/bin/git_bisect +++ b/bin/git_bisect @@ -9,7 +9,7 @@ else echodo git checkout "$1" if echodo "${@:2}"; then echodo git bisect good - git bisect run bash -cl "echodo ${@:2}" + git bisect run echodo "${@:2}" echodo git bisect reset else echodo git bisect reset diff --git a/bin/git_bisect_branch b/bin/git_bisect_branch index ea7595c..6b95b74 100755 --- a/bin/git_bisect_branch +++ b/bin/git_bisect_branch @@ -3,7 +3,7 @@ # TODO: test if echodo "$@"; then - echo ${COLOR_GREEN}HEAD passes${COLOR_RESET}; + echo $'\033'"[32mHEAD passes"$'\033'[m; else echodo git bisect reset; echodo git bisect start; @@ -11,7 +11,7 @@ else echodo git checkout "$(git_branch_fork_point)"; if echodo "$@"; then echodo git bisect good; - git bisect run bash -cl "echodo $*"; + git bisect run echodo "$@" echodo git bisect reset; else echodo git bisect reset; diff --git a/bin/git_rebase_exec b/bin/git_rebase_exec index cf2bde7..be0dac6 100755 --- a/bin/git_rebase_exec +++ b/bin/git_rebase_exec @@ -1,3 +1,3 @@ #!/usr/bin/env bash - git_can_autostash && ( git_rebase_i --exec="bash -cl '${*:2}'" "$1" --reschedule-failed-exec ) +git_can_autostash && ( git_rebase_i --exec="${*:2}" "$1" --reschedule-failed-exec ) diff --git a/bin/git_uncommit b/bin/git_uncommit deleted file mode 100755 index 4a29423..0000000 --- a/bin/git_uncommit +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - - echodo git reset --quiet HEAD^ diff --git a/functions/colors b/functions/colors index f600c3d..d49ac25 100644 --- a/functions/colors +++ b/functions/colors @@ -1,19 +1,12 @@ #!/usr/bin/env bash -export COLOR_RED=$'\033[38;5;125m' -export COLOR_GREEN=$'\033[38;5;48m' -export COLOR_YELLOW=$'\033[38;5;227m' -export COLOR_BLUE=$'\033[1;34m' -export COLOR_AQUA=$'\033[1;36m' -export COLOR_GREY=$'\033[0;90m' -export COLOR_RESET=$'\033[0m' # Have less display colours # from: https://wiki.archlinux.org/index.php/Color_output_in_console#man -export LESS_TERMCAP_mb=$COLOR_BLUE # begin bold -export LESS_TERMCAP_md=$COLOR_GREEN # begin blink +export LESS_TERMCAP_mb=$'\e[1;34m' # begin bold +export LESS_TERMCAP_md=$'\e[1;32m' # begin blink export LESS_TERMCAP_so=$'\e[01;44;37m' # begin reverse video -export LESS_TERMCAP_us=$COLOR_AQUA # begin underline -export LESS_TERMCAP_me=$COLOR_RESET # reset bold/blink -export LESS_TERMCAP_se=$COLOR_RESET # reset reverse video -export LESS_TERMCAP_ue=$COLOR_RESET # reset underline +export LESS_TERMCAP_us=$'\e[1;36m' # begin underline +export LESS_TERMCAP_me=$'\e[m' # reset bold/blink +export LESS_TERMCAP_se=$'\e[m' # reset reverse video +export LESS_TERMCAP_ue=$'\e[m' # reset underline diff --git a/functions/git_alias_completion.sh b/functions/git_alias_completion.sh index dbcbe86..d031a28 100644 --- a/functions/git_alias_completion.sh +++ b/functions/git_alias_completion.sh @@ -18,4 +18,4 @@ __git_complete cc_menu_add __git_complete_refs __git_complete git_branch_D __git_complete_refs __git_complete git_branch_rm __git_complete_refs __git_complete gg __git_complete_remote_or_refspec -__git_complete git_get __git_complete_remote_or_refspec +__git_complete git-get __git_complete_remote_or_refspec diff --git a/gitconfig b/gitconfig index 888a33c..2f81e01 100644 --- a/gitconfig +++ b/gitconfig @@ -29,12 +29,6 @@ short = true [rerere] enabled = true -[alias] - unstage = ! bash -lc git_unstage - purge = ! bash -lc git_purge - uncommit = ! bash -lc git_uncommit - get = "!f() { bash -lc \"git_get $1\"; }; f" - reword = "!f() { bash -lc \"git_reword $1\"; }; f" [log] mailmap = true [commit] diff --git a/spec/git_spec.rb b/spec/git_spec.rb index 41502ac..3b4cff2 100644 --- a/spec/git_spec.rb +++ b/spec/git_spec.rb @@ -166,7 +166,7 @@ end end - describe 'git_reword' do + describe 'git reword' do it 'can reword the commit message' do git_checkout('-b branch') file('a').write('a') @@ -180,7 +180,7 @@ sha_by_alias = run('git rev-parse --short HEAD^') expect(sha_by_alias).to have_output(/\A\h+\n\z/) expect(sha_by_name.output.to_s).to eq sha_by_alias.output.to_s - expect(run("git_reword 'to be changed'", + expect(run("git reword 'to be changed'", env: { GIT_EDITOR: "sed -i.~ 's/to be changed/was changed/'" })) .not_to have_output expect(git_log).to have_output(