vcs: Restructure vcs module
Just like writing and qutebrowser modules, restructured the version control software module to make more use of dotter's ability to precisely link files. All contained programs have a top-level directory and all the files that correspond to that specific software lie beneath in the directory tree.
This commit is contained in:
parent
0b6f0c235d
commit
bcd93eb237
8 changed files with 9 additions and 3 deletions
15
vcs/gitignore/config/zsh/completions/_gitignore
Executable file
15
vcs/gitignore/config/zsh/completions/_gitignore
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#compdef _gitignore gitignore
|
||||
#
|
||||
# Requires gitignore script in path
|
||||
#
|
||||
# Enables completion for zsh of gitignore function.
|
||||
|
||||
_gitignore_get_command_list() {
|
||||
curl -sL https://www.gitignore.io/api/list | tr ',' '\n'
|
||||
}
|
||||
|
||||
_gitignore() {
|
||||
_arguments \
|
||||
'1::flags:((-f\:"Save output to .gitignore file in current directory"))' \
|
||||
":listopts: _values -s, 'modules' $(_gitignore_get_command_list)"
|
||||
}
|
||||
79
vcs/gitignore/local/bin/gitignore
Executable file
79
vcs/gitignore/local/bin/gitignore
Executable file
|
|
@ -0,0 +1,79 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
# Adds call to gitignore.sh api to automatically
|
||||
# generate a .gitignore file with the individual arguments
|
||||
# passed in included as ignored packages.
|
||||
#
|
||||
# Pass in -f as first argument to save the file as .gitignore
|
||||
# in the current directory in addition to printing to stdout.
|
||||
# Will *overwrite* any previous .gitignore file that exists in
|
||||
# current directory.
|
||||
#
|
||||
# When called without arguments will load all possible arguments
|
||||
# as fzf searchable list if fzf is in path.
|
||||
#
|
||||
# Enables completion for zsh in git/.config/shell/zshrc.d/_gitignore_completions.zsh
|
||||
|
||||
__get_items() {
|
||||
if [ "$1" = "" ]; then
|
||||
echo "gitignore definition generation needs at least one argument."
|
||||
exit 1
|
||||
fi
|
||||
if [ "$savetofile" = "true" ]; then
|
||||
__call_url "$@" >>.gitignore
|
||||
else
|
||||
__call_url "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
__call_url() {
|
||||
IFS=","
|
||||
curl -L -s https://www.gitignore.io/api/"$*"
|
||||
}
|
||||
|
||||
gitignore() {
|
||||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
||||
usage
|
||||
exit 0
|
||||
# just print to stdout or save locally?
|
||||
elif [ "$1" = "-f" ] || [ "$1" = "--file" ]; then
|
||||
savetofile=true
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=","
|
||||
if [ "$#" -eq 0 ]; then
|
||||
if type fzf >/dev/null 2>&1; then
|
||||
for item in $(__get_items list); do
|
||||
echo "$item"
|
||||
done | fzf --multi --ansi | paste -s -d "," - |
|
||||
{ read -r result && __get_items "$result"; }
|
||||
else
|
||||
usage
|
||||
fi
|
||||
else
|
||||
__get_items "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
usage() {
|
||||
printf "%s\n" \
|
||||
"" \
|
||||
" gitignore Quickly generate a gitignore definition." \
|
||||
"" \
|
||||
" Usage: gitignore [-h] [vim] [linux] [javascript] [...]" \
|
||||
"" \
|
||||
" Arguments:" \
|
||||
"" \
|
||||
" -h | --help Print out this help." \
|
||||
"" \
|
||||
" -f | --file Append gitignore definition to .gitignore file" \
|
||||
" instead of stdout." \
|
||||
"" \
|
||||
" Arguments will be passed along to gitignore.io for parsing and " \
|
||||
" gitignore definition generation. By default only prints to stdout." \
|
||||
"" \
|
||||
""
|
||||
}
|
||||
|
||||
gitignore "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue