dotfiles/.bin/ksh-update-completions
2024-01-19 22:17:16 +01:00

35 lines
1.6 KiB
Bash
Executable File

#!/bin/ksh
rm -f "${HOME}/.ksh/complete.ksh"
add() { ( printf '%s %s' "$1" "$2" | tr '\n' ' '; printf '\n') >> "${HOME}/.ksh-complete"; }
if [ -d ~/.password-store ]; then
ARGS="$(cd ~/.password-store && ls -1d */* | sed 's/\.gpg$//g;s/ /\\ /g')"
add "set -A complete_pass -- change edit insert show rm cp mv search find " "$ARGS"
fi
if [ -f ${HOME}/.ssh/config ]; then
add "set -A complete_ssh -- " "$(awk '/^Host .*/ { print $2 }' ${HOME}/.ssh/config)"
fi
add "set -A complete_kill_1 -- " "-9 -HUP -INFO -KILL -TERM"
add "set -A complete_ifconfig_1 -- " "$(ifconfig | grep ^[a-z] | cut -d: -f1)"
add "set -A complete_amused_1 -- " "add flush jump load monitor next pause play prev repeat restart show status stop toggle"
add "set -A complete_got_1 -- " "$(got -h 2>&1 | sed -n s/commands://p)"
ARGS="install uninstall test update-patches update-plist lib-depends-check port-lib-depends-check clean show="
add "set -A complete_make_1 -- " "$ARGS"
ARGS="reload restart stop start disable enable ls"
add "set -A complete_rcctl_1 -- " "$ARGS"
add "set -A complete_rcctl_2 -- " "$(rcctl ls all)"
add "set -A complete_got_1 -- " "$(got -h 2>&1 | sed -n s/commands://p)"
add "set -A complete_xdl_1 -- " "$(cd ~/x && ls -d *)"
add "set -A complete_ytdl_1 -- " "$(cd ~/Videos/YouTube && ls -d *)"
add "set -A complete_cg -- " "bitreich cufflink efnet hackint ircnet liberachat oftc robustirc uugrn"
add "set -A complete_man -- " "port-modules bsd.port.mk ports packages dpb make ffmpeg-complete mpv cabal-module cargo-module go-module gnome-module python-module qmake-module ruby-module cargo"