Improve gi function

Former-commit-id: e240d73260
This commit is contained in:
Wenxuan 2018-03-24 10:23:17 +08:00
parent b27df403d7
commit bbcb7fbf20

View file

@ -65,11 +65,23 @@ gi() {
local preview="echo {} |awk '{print \$2}' |xargs -I% bash -c 'cat $giCache/% 2>/dev/null || (curl -sL https://www.gitignore.io/api/% |tee $giCache/%)'"
IFS=$'\n'
[[ $# -gt 0 ]] && args=($@) || args=($(cat $giIndex |nl -nrn -w4 -s' ' |fzf -m --preview="$preview" --preview-window="right:70%" |awk '{print $2}'))
gi-get ${args[@]}
}
GI() {
inside_work_tree || return 1
gi >> .gitignore
test -z "$args" && return 1
local options=(
'(1) Output to stdout'
'(2) Append to .gitignore'
'(3) Overwrite .gitignore')
opt=$(printf '%s\n' "${options[@]}" |fzf |awk '{print $1}')
case "$opt" in
'(1)' )
gi-get ${args[@]}
;;
'(2)' )
gi-get ${args[@]} >> .gitignore
;;
'(3)' )
gi-get ${args[@]} > .gitignore
;;
esac
}
gi-update-index() {
mkdir -p $giCache