fix ga script
This commit is contained in:
parent
fea17f0609
commit
96969ca538
@ -1,20 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
_fzf_base() {
|
||||
fzf -0 -m --bind load:last "${@}" | cut -d' ' -f2
|
||||
fzf -0 -m --bind load:last --print0 "${@}" | sed -z 's/^[^ ]* //'
|
||||
}
|
||||
|
||||
fzf_get_selected_modified() {
|
||||
_fzf_base -1 --border-label=' Modified ' --preview 'git diff --color=always {2}'
|
||||
_fzf_base -1 --border-label=' Modified ' --preview 'git diff --color=always -- "$(echo {+} | sed "s/^[^ ]* //")"'
|
||||
}
|
||||
|
||||
fzf_get_selected_untracked() {
|
||||
_fzf_base --border-label=' Untracked ' --preview 'highlight -O xterm256 {2}'
|
||||
_fzf_base --border-label=' Untracked ' --preview 'highlight -O xterm256 -- "$(echo {+} | sed "s/^[^ ]* //")"'
|
||||
}
|
||||
|
||||
gitadd() {
|
||||
xargs git add
|
||||
xargs -0 git add
|
||||
}
|
||||
|
||||
git_ls_files() {
|
||||
@ -22,7 +21,11 @@ git_ls_files() {
|
||||
}
|
||||
|
||||
modified_files="$(git_ls_files --modified)"
|
||||
printf "%s" "${modified_files}" | fzf_get_selected_modified | gitadd
|
||||
if [ -n "$modified_files" ]; then
|
||||
printf "%s\n" "${modified_files}" | fzf_get_selected_modified | gitadd
|
||||
fi
|
||||
|
||||
untracked_files="$(git_ls_files --others)"
|
||||
printf "%s" "${untracked_files}" | fzf_get_selected_untracked | gitadd
|
||||
if [ -n "$untracked_files" ]; then
|
||||
printf "%s\n" "${untracked_files}" | fzf_get_selected_untracked | gitadd
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user