Add comment to bash g completion script and reindent
This commit is contained in:
parent
9c6ecb6426
commit
4ef004e60c
1 changed files with 15 additions and 12 deletions
|
@ -1,16 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Just source this file in your bashrc :)
|
||||||
|
|
||||||
_g_completion() {
|
_g_completion() {
|
||||||
root=$(git rev-parse --show-toplevel 2>/dev/null)
|
root=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||||
if [ "$root" ]
|
if [ "$root" ]
|
||||||
then
|
then
|
||||||
if echo "$2" | grep '^\/' > /dev/null
|
if echo "$2" | grep '^\/' > /dev/null
|
||||||
then
|
then
|
||||||
dirname=$(dirname "$2foo")
|
dirname=$(dirname "$2foo")
|
||||||
regex=$(echo $root | sed 's/\//\\\//g')
|
regex=$(echo $root | sed 's/\//\\\//g')
|
||||||
for dir in $(find $root$dirname -maxdepth 1 -mindepth 1 -type d | sed s'/^'"$regex"'//g' | grep '^'"$2")
|
for dir in $(find $root$dirname -maxdepth 1 -mindepth 1 -type d | sed s'/^'"$regex"'//g' | grep '^'"$2")
|
||||||
do COMPREPLY+=("$dir/")
|
do COMPREPLY+=("$dir/")
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
complete -F _g_completion -o bashdefault -o dirnames g
|
complete -F _g_completion -o bashdefault -o dirnames g
|
||||||
|
|
Loading…
Reference in a new issue