changed folder layout
This commit is contained in:
parent
6a1f0cce72
commit
baa2119b5f
15 changed files with 1619 additions and 0 deletions
53
cfg/zsh/cfg.d/source.d/function-gitignore.zsh
Normal file
53
cfg/zsh/cfg.d/source.d/function-gitignore.zsh
Normal file
|
@ -0,0 +1,53 @@
|
|||
export ZSH_PLUGIN_GITIGNORE_PATH=$(dirname $0)
|
||||
export ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS=${DOTLIB}/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
|
||||
|
||||
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