Skip to content

Instantly share code, notes, and snippets.

@hboon
Created August 31, 2023 11:12
Show Gist options
  • Save hboon/56bd6cc33dcb7fa0589becd645c70be0 to your computer and use it in GitHub Desktop.
Save hboon/56bd6cc33dcb7fa0589becd645c70be0 to your computer and use it in GitHub Desktop.
Fish shell function to search for a commit on (tmux) screen, generate a branch name and run `gco -b <new-branch> <hash>`
#Use this to do `gco -b <branch> <commit>`
function pr
set --local hash (gcommit)
#echo "in our pr: $hash"
set --local msg (git show -s --format=%B $hash | head -1)
#echo "in our pr: $msg"
set --local branch (string lower $msg | string replace -a -r "[ /#]" "-" | string replace -a -r "[\(\)\.\[\]'`\":]" "")
#echo "in our pr: $branch"
echo "Running: git checkout -b $branch $hash"
git checkout -b $branch $hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment