ksh-completion

Korn shell completion installer
Log | Files | Refs

commit 93fd0cff81566691d969181c10cf9a8adb184f03
parent 0c15ad4f67a266fa66fb716b15d9bea78eca3c5d
Author: Miniontoby <tobias.gaarenstroom@gmail.com>
Date:   Tue, 11 Jan 2022 13:28:20 +0000

Made updater work

Diffstat:
Minstall.sh | 38++++++++++++++++++++++++++++++++++++--
Dksh_completion | 208-------------------------------------------------------------------------------
2 files changed, 36 insertions(+), 210 deletions(-)

diff --git a/install.sh b/install.sh @@ -1,6 +1,40 @@ #!/bin/ksh -if [ "$SHELL" \!= "/bin/ksh" ]; then - echo "You should be using ksh for ksh-completion!" +function error { + echo "$1" exit 1 +} + +if [[ "`id -u`" -eq 0 ]]; then + echo -e "Checking Root User(Oke)" +else + echo -e "Checking Root User(Failed). Switching to root user" + doas ksh $0 + exit 0 +fi + +PROFILE_SHELL=`sh -c 'ps -p $$ -o ppid=' | xargs ps -o comm= -p` +if [ "$PROFILE_SHELL" \!= "ksh" ]; then + error "You should be using ksh for ksh-completion!" fi +wget -O /tmp/ksh_completion "https://ircforever.org/ksh_completion" + +USERS=$(ls /home) + +for USER in $USERS; do + cp /tmp/ksh_completion /home/$USER/.ksh_completions + if [ \! -f /home/$USER/.kshrc ]; then + if grep -q "if [ -e ~/.ksh_completions ]; then . ~/.ksh_completions fi" /home/$USER/.profile; then + continue + else + echo "if [ -e ~/.ksh_completions ]; then . ~/.ksh_completions fi" >> /home/$USER/.profile + fi + else + if grep -q "if [ -e ~/.ksh_completions ]; then . ~/.ksh_completions fi" /home/$USER/.kshrc; then + continue + else + echo "if [ -e ~/.ksh_completions ]; then . ~/.ksh_completions fi" >> /home/$USER/.kshrc + fi + fi +done + diff --git a/ksh_completion b/ksh_completion @@ -1,208 +0,0 @@ -function reload_completions { - if [ -e ~/.ksh_completions ]; then . ~/.ksh_completions; fi -} - -set -A complete_got_1 -- $(got -h 2>&1 | sed -n s/commands://p) -set -A complete_git_1 -- $(git help -a | sed -e 's/ //;s/ .*//;s/.*\/.*//;s/.* .*//') -set -A complete_kill_1 -- -9 -HUP -INFO -KILL -TERM -set -A complete_kill_2 -- $(ps ax | sed -e "s/^ *//" -e "s/ .*//") - -pgrep -q vmd -if [ $? = 0 ]; then - set -A complete_vmctl -- console load reload start stop reset status send receive - set -A complete_vmctl_2 -- $(vmctl status | awk '!/NAME/{print $NF}') -fi - -pgrep -q mpd -if [ $? = 0 ]; then - set -A complete_mpc_1 -- lsplaylists ls play pause toggle prev random shuffle stop update - set -A complete_mpc_2 -- $(mpc lsplaylists | sort) -fi - -read_known_hosts() { - local _file=$1 _line _host - while read _line ; do - _line=${_line%%#*} # delete comments - _line=${_line%%@*} # ignore markers - _line=${_line%% *} # keep only host field - - [[ -z $_line ]] && continue - - local IFS=, - for _host in $_line; do - _host=${_host#\[} - _host=${_host%%\]*} - for i in ${HOST_LIST[*]}; do - [[ $_host == $i ]] && continue 2 - done - set -s -A HOST_LIST ${HOST_LIST[*]} $_host - done - done <$_file -} - -[[ -s /etc/ssh/ssh_known_hosts ]] && read_known_hosts /etc/ssh/ssh_known_hosts -[[ -s ~/.ssh/known_hosts ]] && read_known_hosts ~/.ssh/known_hosts - -set -A complete_ssh -- ${HOST_LIST[*]} -set -A complete_scp -- ${HOST_LIST[*]} -set -A complete_mosh -- ${HOST_LIST[*]} - -if [ -d /var/db/pkg ]; then - PKG_LIST=$(ls -1 /var/db/pkg) - set -A complete_pkg_delete -- $PKG_LIST - set -A complete_pkg_info -- $PKG_LIST - set -A complete_pkg_check -- $PKG_LIST - set -A complete_pkg_add -- $PKG_LIST -fi - -if [ ! -f /tmp/man_list ]; then - MANPATH=/usr/share/man man -k Nm~. | cut -d\( -f1 | tr -d , | sort | uniq > /tmp/man_list -fi -set -A complete_man_1 -- $(cat /tmp/man_list) - -pgrep -fq '/usr/sbin/vmd' -if [ $? = 0 ]; then - set -A complete_vmctl -- console load reload start stop reset status send receive - set -A complete_vmctl_2 -- $(vmctl status | awk '!/NAME/{print $NF}') -fi - -if [ -e /usr/local/bin/rclone ]; then - if [ -f ~/.config/rclone/rclone.conf ]; then - RCLONE_LIST=$(rclone listremotes) - set -A complete_rclone_1 -- \ - about authorize \ - cachestats cat check cleanup config copy copyto \ - copyurl cryptcheck \ cryptdecode \ - dbhashsum dedupe delete deletefile \ - genautocomplete gendocs \ - hashsum help \ - link listremotes ls lsd lsf lsjson lsl \ - md5sum mkdir move moveto \ - ncdu \ - obscure \ - purge \ - rc rcat rcd rmdir rmdirs \ - serve settier sha1sum size sync \ - touch tree \ - version - set -A complete_rclone -- $RCLONE_LIST - fi -fi - -if [ -x /usr/rbin/rcctl ]; then - set -A complete_rcctl_1 -- disable enable get ls order set restart start stop - set -A complete_rcctl_2 -- $(rcctl ls all) -fi - -set -A complete_make_1 -- \ - clean \ - install \ - port-lib-depends-check \ - reinstall \ - repackage - -set -A complete_rcctl_1 -- disable enable get ls order set restart start stop -set -A complete_rcctl_2 -- $(rcctl ls all) - -set -A complete_signify_1 -- -C -G -S -V -set -A complete_signify_2 -- -q -p -x -c -m -t -z -set -A complete_signify_3 -- -p -x -c -m -t -z - -set -A complete_make_1 -- install clean repackage reinstall - -set -A complete_beet_1 -- as clearart config duplicates embedart extractart fetchart fields fingerprint help import lastgenre list lyrics \ - mbsync missing modify move mpdstats remove scrub splupdate stats submit update version web write - -set -A complete_emacs -- --daemon --debug-init -set -A complete_emacsclient -- -c -t - -set -A complete_gpg2 -- \ - --armor \ - --clearsign \ - --decrypt \ - --detach-sig \ - --list-key \ - --receive-keys \ - --refresh \ - --sign \ - --verify - - -if [ -f /dev/mixer ]; then - set -A complete_mixerctl_1 -- $(mixerctl | cut -d= -f 1) -fi - -if [ -d ~/.dynamic-colors ]; then - set -A complete_dynamic_colors -- \ - audit \ - create cycle \ - edit \ - help \ - init \ - list \ - switch - set -A complete_dynamic_colors_2 -- $(dynamic_colors list) -fi - -if [ -e /usr/local/bin/opm ]; then - if [ -d ~/.opm ]; then - set -A complete_opm_1 -- -b -c -d -h -m \ - add \ - del \ - encrypt \ - get \ - insert \ - list ls \ - rm \ - search show \ - verify - set -A complete_opm -- $(/usr/local/bin/opm -b ls) - fi -fi - -if [ -e /usr/local/bin/gopass ]; then - PASS_LIST=$(gopass ls -f) - set -A complete_gopass -- $PASS_LIST \ - audit \ - bin binary \ - clone completion config copy cp create \ - delete \ - edit \ - find fix fsck \ - generate git grep \ - h help hotp \ - init insert \ - jsonapi \ - list ls \ - mounts move mv \ - new \ - otp \ - recipients remove rm \ - search set setup show sync \ - templates totp \ - unclip update \ - version - set -A complete_pass -- $PASS_LIST \ - audit \ - bin binary \ - clone completion config copy cp create \ - delete \ - edit \ - find fix fsck \ - generate git grep \ - h help hotp \ - init insert \ - jsonapi \ - list ls \ - mounts move mv \ - new \ - otp \ - recipients remove rm \ - search set setup show sync \ - templates totp \ - unclip update \ - version -fi - -set -A complete_hg_1 -- add annotate clone commit diff export forget help init log merge pull push remove serve status summary update -