changed yet more stuff
This commit is contained in:
parent
a0d198cdcb
commit
7935ec2ef6
23 changed files with 1080 additions and 47 deletions
56
config/zsh/zshrc.d/functions/gitignore.zsh
Normal file
56
config/zsh/zshrc.d/functions/gitignore.zsh
Normal file
|
@ -0,0 +1,56 @@
|
|||
export ZSH_PLUGIN_GITIGNORE_PATH=$(dirname $0)
|
||||
export ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS=${LIB}/gitignore
|
||||
|
||||
function gie () {
|
||||
${EDITOR} .gitignore
|
||||
}
|
||||
|
||||
function gi() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
cat .gitignore
|
||||
return 0
|
||||
fi
|
||||
|
||||
for t in $*; do
|
||||
get_gitignore_template $t
|
||||
done
|
||||
}
|
||||
|
||||
function gii() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
cat .gitignore
|
||||
return 0
|
||||
fi
|
||||
|
||||
# if NOCLOBBER option is setted
|
||||
gi $* >>! .gitignore
|
||||
}
|
||||
|
||||
function get_gitignore_template() {
|
||||
for tpath in ${(@s/:/)ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS}; do;
|
||||
local file=$(find $tpath -iname "$1.gitignore")
|
||||
if [[ ! -z $file ]]; then
|
||||
comment=$(basename $file | sed -e 's/.gitignore$//')
|
||||
echo
|
||||
echo "### $comment"
|
||||
cat $file
|
||||
break;
|
||||
fi
|
||||
done;
|
||||
}
|
||||
|
||||
_gitignore_get_template_list() {
|
||||
(for tpath in ${(@s/:/)ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS}; do; find $tpath -type f -name "*.gitignore"; done) \
|
||||
| xargs -n 1 basename \
|
||||
| sed -e 's/.gitignore$//' -e 's/\(.*\)/\L\1/' \
|
||||
| sort -u
|
||||
}
|
||||
|
||||
_gitignore () {
|
||||
compset -P '*,'
|
||||
compadd -S '' `_gitignore_get_template_list`
|
||||
}
|
||||
|
||||
compdef _gitignore gi
|
||||
compdef _gitignore gii
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue