From 4ae9881d258bdb6155dbe2eaae0631605903999c Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Tue, 23 Oct 2018 09:47:19 +0200 Subject: [PATCH] completion --- dirs.sh | 1 + shell/.bash_completion | 1 + shell/.bash_completion.d/clm | 50 +++++++++++ shell/.bash_completion.d/cpm | 115 ++++++++++++++++++++++++++ shell/.local/bin/latex.mk | 24 ------ vim/.vim/pack/plugins/start/syntastic | 2 +- vim/.vim/pack/plugins/start/vim-clean | 2 +- vim/.vim/pack/plugins/start/vim-praat | 2 +- vim/.vim/pack/plugins/start/vimtex | 2 +- 9 files changed, 171 insertions(+), 28 deletions(-) create mode 100644 shell/.bash_completion create mode 100644 shell/.bash_completion.d/clm create mode 100644 shell/.bash_completion.d/cpm delete mode 100644 shell/.local/bin/latex.mk diff --git a/dirs.sh b/dirs.sh index df73377..bcf64f2 100644 --- a/dirs.sh +++ b/dirs.sh @@ -1,5 +1,6 @@ mkdir -pv ~/.config/{khal,khard,vdirsyncer,todoman,notmuch,msmtp,offlineimap,dunst,tmux} mkdir -pv ~/.mutt +mkdir -pv ~/.bash_completion.d mkdir -pv ~/.gnupg mkdir -pv ~/.vim/{ftplugin,after/ftplugin,autoload,bundle,spell,pack/plugins/{opt,start}} mkdir -pv ~/.local/bin diff --git a/shell/.bash_completion b/shell/.bash_completion new file mode 100644 index 0000000..0591bba --- /dev/null +++ b/shell/.bash_completion @@ -0,0 +1 @@ +for f in ~/.bash_completion.d/*; do . "$f"; done diff --git a/shell/.bash_completion.d/clm b/shell/.bash_completion.d/clm new file mode 100644 index 0000000..9eb873d --- /dev/null +++ b/shell/.bash_completion.d/clm @@ -0,0 +1,50 @@ +_clm() +{ + local cur prev opts + COMPRREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + opts="-I -IL -P -w -nw -d -nd -sa -nsa -mv -ms -O -PO -S -PS -ABC -PABC -c -lt -nlt -lat -nlat -lset -ci -nci -ou -nou -fusion -nfusion -pt -npt -desc -exl -tst -funcmayfail -varnotused -funcnotused -nowarn -ns -no-opt-link -l -sl -e -E -aC -h -s -b -sc -t -nt -gc -ngc -st -nst -nr -gcm -gcc -gcf -gci -dynamics -nortsopts -p -pic -optabc -bytecode" + + case $prev in + "-IL") + # Complete Clean libraries + opts="$(find "$CLEAN_HOME/lib" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)" + COMPREPLY=($(compgen -W "$opts" -- $cur)) + return 0 + ;; + "-I") + # Complete directories + _filedir + for index in "${!COMPREPLY[@]}"; do + [ -d "${COMPREPLY[index]}" ] || unset -v 'COMPREPLY[$index]' + done + return 0 + ;; + "-l" | "-sl") + # Complete files + _filedir + for index in "${!COMPREPLY[@]}"; do + [ -f "${COMPREPLY[index]}" ] || unset -v 'COMPREPLY[$index]' + done + return 0 + ;; + "-P" | "-e" | "-E" | "-h" | "-s" | "-gcf" | "-gci") + # Complete nothing + return 0 + ;; + esac + + if [[ $cur == -* ]]; then + # Complete options + COMPREPLY=($(compgen -W "$opts" -- $cur)) + return 0 + else + # Main module; complete icl module names + opts="$(find -name '*.icl' -maxdepth 4 -type f -print 2>/dev/null | sed 's:^\./::;s:/:.:g;s:\.icl$::' | grep -v '[- ]')" + COMPREPLY=($(compgen -W "$opts" -- $cur)) + return 0 + fi +} +complete -F _clm clm diff --git a/shell/.bash_completion.d/cpm b/shell/.bash_completion.d/cpm new file mode 100644 index 0000000..b4ce889 --- /dev/null +++ b/shell/.bash_completion.d/cpm @@ -0,0 +1,115 @@ +# bash completion for cpm +# Author: Mart Lubbers +# Date: 2018-07-17 +# +# Todo +# - support --envs=filename +# - create completion for module +# - create completion for environment +# - test on non-linux +_set_opts="-generic_fusion -ngeneric_fusion -dynamics -ndynamics -descexl -ndescexl -b -nr -nc -sc" + +_targets() +{ + sed 's/EnvironmentName:[[:space:]]*//;t;d' | tr -d '\n' +} + +_paths() +{ + sed 's/\[\([[:digit:]]\)\].*/\1/;t;d' | tr -d '\n' +} + +_cpm() +{ + local arg cur prev words cword split + + # Require bash completion + _init_completion || return + _get_first_arg + _get_comp_words_by_ref + + # subcommand or project file + if [[ -z "${arg}" ]] + then + COMPREPLY=( $(compgen -W "environment project module make" -- ${cur}) ) + _filedir prj + else + case "${arg}" in + *.prj) + COMPREPLY=( $(compgen -W "--force" -- ${cur}) ) + ;; + make) + ;; + project) + # Not even a project file is selected + if [[ "$cword" = 2 ]] + then + _filedir prj + # A project file is selected + elif [[ "$cword" = 3 ]] + then + COMPREPLY=( $(compgen -W "create show build path root target exec set" -- ${cur}) ) + # A project command is selected + elif [[ "$cword" -ge 4 ]] + then + case "${words[3]}" in + build) + COMPREPLY=( $(compgen -W "--force --envs" -- ${cur}) ) + ;; + path) + # No path command set yet + if [[ "$cword" = 4 ]] + then + COMPREPLY=( $(compgen -W "add list remove move" -- ${cur}) ) + # Path command is set + elif [[ "$cword" -ge 5 ]] + then + case "${words[4]}" in + add) + _filedir -d + ;; + list) + ;; + remove) + COMPREPLY=( $(compgen -W "$("${words[0]}" project "${words[2]}" path list | _paths)" -- ${cur}) ) + ;; + move) + if [[ "$cword" = 5 ]] + then + COMPREPLY=( $(compgen -W "$("${words[0]}" project "${words[2]}" path list | _paths)" -- ${cur}) ) + elif [[ "$cword" = 6 ]] + then + COMPREPLY=( $(compgen -W "up down top bottom" -- ${cur}) ) + fi + ;; + esac + fi + ;; + root) + COMPREPLY=( $(compgen -W ". .. ... .... ....." -- ${cur}) ) + ;; + target) + COMPREPLY=( $(compgen -W "$(_targets < "$CLEAN_HOME/etc/IDEEnvs")" -- ${cur}) ) + ;; + set) + COMPREPLY=( $(compgen -W "$_set_opts" -- ${cur}) ) + ;; + exec) + ;; + create) + ;; + show) + ;; + main) + _filedir + ;; + esac + fi + ;; + module) + ;; + environment) + ;; + esac + fi +} && complete -F _cpm cpm diff --git a/shell/.local/bin/latex.mk b/shell/.local/bin/latex.mk deleted file mode 100644 index ad46f07..0000000 --- a/shell/.local/bin/latex.mk +++ /dev/null @@ -1,24 +0,0 @@ -.PHONY: clean clobber all - -DOCUMENT:=$(shell grep -Fl documentclass *.tex) -LATEX?=pdflatex -LATEXFLAGS?=-synctex=1 -no-shell-escape -file-line-error -halt-on-error -BIBTEX?=bibtex -MAKEGLOSSARIES?=makeglossaries -MAKEINDEX?=makeindex - -all: $(patsubst %.tex,%.pdf,$(shell grep -Fl documentclass *.tex)) - -%.pdf: %.tex $(wildcard *.tex) - $(LATEX) $(LATEXFLAGS) $* - grep -q '^\\bibdata{' $*.aux && $(BIBTEX) $(BIBTEXFLAGS) $* || true - grep -q '\@istfilename' $*.aux && $(MAKEGLOSSARIES) $(MAKEGLOSSARIESFLAGS) $* || true - [ -f $*.idx ] && $(MAKEINDEX) $(MAKEINDEXFLAGS) $* || true - $(LATEX) $(LATEXFLAGS) $* - $(LATEX) $(LATEXFLAGS) $* - -clean: - $(RM) $(addprefix *.,acn acr alg aux bbl blg fmt glg glo gls idx ilg ind ist loa lof log lol lot nav out snm tdo toc vrb) - -clobber: clean - $(RM) -i *.pdf diff --git a/vim/.vim/pack/plugins/start/syntastic b/vim/.vim/pack/plugins/start/syntastic index 0dde090..89e485c 160000 --- a/vim/.vim/pack/plugins/start/syntastic +++ b/vim/.vim/pack/plugins/start/syntastic @@ -1 +1 @@ -Subproject commit 0dde090ed41b383b1fa56f8db49d89e0735b1ca9 +Subproject commit 89e485c7f8b1f285b43bb397394f22b79021aac1 diff --git a/vim/.vim/pack/plugins/start/vim-clean b/vim/.vim/pack/plugins/start/vim-clean index 55dfb22..b9115ca 160000 --- a/vim/.vim/pack/plugins/start/vim-clean +++ b/vim/.vim/pack/plugins/start/vim-clean @@ -1 +1 @@ -Subproject commit 55dfb2276588f4e87eb9ba1c949401cb29343360 +Subproject commit b9115cac07f3db72301738a5c71eb09dfc7b1113 diff --git a/vim/.vim/pack/plugins/start/vim-praat b/vim/.vim/pack/plugins/start/vim-praat index 99d318e..a63f632 160000 --- a/vim/.vim/pack/plugins/start/vim-praat +++ b/vim/.vim/pack/plugins/start/vim-praat @@ -1 +1 @@ -Subproject commit 99d318ed8da0d398de6e9c7f28a4aed2152e34a0 +Subproject commit a63f632928ef25e4b26b2f32f3c9bb12a09f8c2a diff --git a/vim/.vim/pack/plugins/start/vimtex b/vim/.vim/pack/plugins/start/vimtex index 4736043..52f5303 160000 --- a/vim/.vim/pack/plugins/start/vimtex +++ b/vim/.vim/pack/plugins/start/vimtex @@ -1 +1 @@ -Subproject commit 4736043c8920d071ef09d2a01aaadb6cd02d7ad3 +Subproject commit 52f5303ddf641748fe73f5d49e8fa216f865af1a -- 2.20.1