From d74d65f667acabb24e90420956d24c8eb82618a3 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Thu, 23 Dec 2021 11:27:50 +0530 Subject: [PATCH] fish: functions/gl: Allow passing an argument & support cherry picking a commit This allows us to specify a directory or file to run this git log command on. Also add support for cherry-picking a commit. --- fish/.config/fish/functions/gl.fish | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fish/.config/fish/functions/gl.fish b/fish/.config/fish/functions/gl.fish index a50605a..dffaad2 100644 --- a/fish/.config/fish/functions/gl.fish +++ b/fish/.config/fish/functions/gl.fish @@ -4,18 +4,20 @@ function gl --description 'Git browse commits' set -l view_commit_nvim "$log_line_to_hash | xargs -I % sh -c 'git show %'" set -l copy_commit_hash "$log_line_to_hash | wl-copy" set -l git_checkout "$log_line_to_hash | xargs -I % sh -c 'git checkout %'" + set -l git_cherry_pick "$log_line_to_hash | xargs -I % sh -c 'git cherry-pick %'" set -l open_cmd "xdg-open" set github_open "$log_line_to_hash | xargs -I % sh -c '$open_cmd https://github.\$(git config remote.origin.url | cut -f2 -d. | tr \':\' /)/commit/%'" - git log --color=always --format='%C(auto)%h%d %s %C(green)%C(bold)%cr% C(blue)%an' | \ + git log --color=always --format='%C(auto)%h%d %s %C(green)%C(bold)%cr% C(blue)%an' $argv | \ fzf --exact --no-sort --reverse --tiebreak=index --no-multi --ansi \ --preview="$view_commit" \ - --header="ENTER to view, CTRL-Y to copy hash, CTRL-O to open on GitHub, CTRL-X to checkout, CTRL-C to exit" \ + --header="ENTER to view, CTRL-Y to copy hash, CTRL-O to open on GitHub, CTRL-X to checkout, CTRL-C to exit, CTRL-S to cherry-pick" \ --bind "enter:execute:$view_commit_nvim | nvim -R -" \ --bind "ctrl-y:execute:$copy_commit_hash" \ --bind "ctrl-x:execute:$git_checkout" \ --bind "ctrl-o:execute:$github_open" \ + --bind "ctrl-s:execute:$git_cherry_pick" \ --bind "ctrl-d:half-page-down,ctrl-u:half-page-up,ctrl-n:preview-down,ctrl-p:preview-up,ctrl-f:preview-page-down,ctrl-b:preview-page-up" end