From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Mon, 26 Oct 2020 15:13:54 +0000 (-0400) Subject: properly added shell completions X-Git-Url: https://git.armaanb.net/?p=charsel.git;a=commitdiff_plain;h=3175a81c8c551bb01af2dbc2737718dbb3ab0090;ds=sidebyside properly added shell completions --- diff --git a/Makefile b/Makefile index 1ed3a85..d8407fe 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ install: >chmod +x ./charsel >mkdir -p /usr/share/charsel/charfiles/ >cp charfiles/* /usr/share/charsel/charfiles/ +>cp shell-completions /usr/share/charsel/ >mkdir /usr/share/doc/charsel >cp README.md /usr/share/doc/charsel/ >cp ./charsel /usr/bin/ @@ -21,6 +22,7 @@ reinstall: >chmod +x ./charsel >mkdir -p /usr/share/charsel/charfiles/ >cp charfiles/* /usr/share/charsel/charfiles/ +>cp shell-completions /usr/share/charsel/ >mkdir /usr/share/doc/charsel >cp README.md /usr/share/doc/charsel/ >cp ./charsel /usr/bin/ @@ -28,3 +30,7 @@ reinstall: purge: >rm -rf $USER/.local/share/charsel/ >rm -rf $USER/.cache/charsel/ + +install-completions-bash: +>echo "source /usr/share/charsel/shell-completions" >> '${HOME}/.bashrc' +>echo "autoload bashcompinit ; bashcompinit ; source /usr/share/charsel/shell-completions" >> '${ZDOTDIR}/.zshrc' diff --git a/README.md b/README.md index a9f84b8..a370500 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ It uses a plain-text file known as a "charfile" to define easy to reach shortcut ## Usage For argument usage, use `charsel -h` -This script is also so simple that the script itself can basically function as the documentation - Once you [have](have) started the program, simply type the shortcut listed on the left side of the table to copy the character on the right side of the table to your clipboard. Shortcodes the same length as the longest one will automatically be entered. To quit, type ';' as a shortcode Some of the default charfiles have hidden shortcuts for capital letters that are not shown on the table. Simply type a capital version of the shortcut key to access the capital version of the special character. @@ -28,6 +26,9 @@ Make a new file in the `~/.local/share/charsel/charfiles/` or `/usr/share/charse Fill it in, using the provided examples as a template. Hidden shortcuts go above the '-', lines can be commented out using a '#' at the start of the line. ';' cannot be used as a shortcode, as that is used to quit the program +## Shell completions +There is a shell completion script provided. To install it, use `make install-completions` + ## License Charfile is GNU GPLv3 licensed, see COPYING for more information diff --git a/bash-completions b/bash-completions deleted file mode 100755 index 375d8eb..0000000 --- a/bash-completions +++ /dev/null @@ -1,12 +0,0 @@ -_script() -{ - _script_commands=$(charsel -L) - - local cur prev - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - COMPREPLY=( $(compgen -W "${_script_commands}" -- ${cur}) ) - - return 0 -} -complete -o nospace -F _script charsel diff --git a/shell-completions b/shell-completions new file mode 100755 index 0000000..172eb4b --- /dev/null +++ b/shell-completions @@ -0,0 +1,12 @@ +charfiles() +{ + _script_commands=$(charsel -L) + + local cur prev + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + COMPREPLY=( $(compgen -W "${_script_commands}" -- ${cur}) ) + + return 0 +} +complete -o nospace -F charfiles charsel