fish: functions: Check for git repository in git helpers
This commit is contained in:
parent
634515cb34
commit
d18f26ab93
13 changed files with 65 additions and 0 deletions
|
@ -1,4 +1,9 @@
|
|||
function gdd --description "Use difftastic as a difftool"
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
if count $argv >/dev/null
|
||||
git difftool --tool=difftastic $argv
|
||||
else
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
function gdk
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
if count $argv >/dev/null
|
||||
git difftool --tool=kitty $argv
|
||||
else
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
function gdt
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
if count $argv >/dev/null
|
||||
git --no-pager difftool $argv
|
||||
else
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
function git_remote_toggle --description 'Switch git repository between HTTPS and SSH'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l options h/help q/quiet S/ssh H/https
|
||||
argparse $options -- $argv; or return
|
||||
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
function gl --description 'Git browse commits'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l log_line_to_hash "echo {} | grep -o '[a-f0-9]\{7\}' | head -1"
|
||||
set -l view_commit "$log_line_to_hash | xargs -I % sh -c 'git show --color=always % | bat -ldiff'"
|
||||
set -l view_commit_nvim "$log_line_to_hash | xargs -I % sh -c 'git show %'"
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
function glmd --description 'Format commits in markdown for MR descriptions and copy to clipboard'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l remote (git symbolic-ref refs/remotes/origin/HEAD | awk -F'/' '{print $4}')
|
||||
git log --reverse --pretty=format:"- **%s** %w(0,2,2)%+b" origin/$remote.. | wl-copy
|
||||
end
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
function gm
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
if count $argv >/dev/null
|
||||
git merge $argv
|
||||
else
|
||||
|
|
|
@ -2,5 +2,10 @@
|
|||
# ACMRU = Added || Copied || Modified || Renamed || Unmerged
|
||||
# Edit all uncommitted files that have changes since the last commit (be they staged or unstaged)
|
||||
function vd --wraps='nvim (git diff HEAD --name-only --diff-filter=ACMR)' --description 'alias vd=nvim (git diff HEAD --name-only --diff-filter=ACMR)'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
nvim (git diff HEAD --name-only --diff-filter=ACMR) $argv
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
function vdc --wraps='nvim (git diff HEAD^ --name-only --diff-filter=ACMR)' --description 'Edit all files that were altered in the last commit'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
nvim (git diff HEAD^ --name-only --diff-filter=ACMR) $argv
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
function vdm --wraps='nvim (git diff master --name-only --diff-filter=ACMR)' --description 'Edit files changed since master'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
nvim (git diff master --name-only --diff-filter=ACMR) $argv
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
function vds --wraps='nvim (git diff --staged --name-only --diff-filter=ACMR)' --description 'Edit all staged files that have changes since the last commit'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
nvim (git diff --staged --name-only --diff-filter=ACMR) $argv
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
function vdu --wraps='nvim (git diff --name-only --diff-filter=U | uniq)' --description 'Edit files unmerged'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
nvim (git diff --name-only --diff-filter=U | uniq) $argv
|
||||
end
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
function vdua --wraps='git add (git diff --name-only --diff-filter=U)' --description 'Add unmerged files'
|
||||
if not test -d .git
|
||||
echo "Not a git repository"
|
||||
return 0
|
||||
end
|
||||
|
||||
git add (git diff --name-only --diff-filter=U) $argv
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue