Created
February 14, 2020 15:35
-
-
Save djensenius/1765513cace87eebf7db27e6fd1d26ec to your computer and use it in GitHub Desktop.
Fish shortcut function to simplify git --set-upstream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git_new_push --description 'Shortcut to push new branch' | |
if not command -sq git | |
return 1 | |
end | |
set -l repo_info (command git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree HEAD 2>/dev/null) | |
test -n "$repo_info" | |
or return | |
set -l rbc (__fish_git_prompt_operation_branch_bare $repo_info) | |
set -l b $rbc[2] | |
set b (string replace refs/heads/ '' -- $b) | |
git push --set-upstream origin $b | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment