[+] Script to install autocompletion
https://github.com/hykilpikonna/hyfetch/issues/96
This commit is contained in:
parent
365abe2c80
commit
c40cb09409
2 changed files with 64 additions and 2 deletions
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
|
|
||||||
complete hyfetch \
|
complete hyfetch \
|
||||||
'c/--/(version test-distro ascii-file preset c-set-l help debug config-file c-scale config backend mode distro)/' \
|
'c/--/(mode test-distro preset config c-scale c-set-l config-file ascii-file version debug distro help backend)/' \
|
||||||
'c/-/(C m V h p b c -)/' \
|
'c/-/(m h V C p b c -)/' \
|
||||||
'n/-p/(rainbow transgender nonbinary agender queer genderfluid bisexual pansexual polysexual omnisexual omniromantic gay-men lesbian abrosexual asexual aromantic aroace1 aroace2 aroace3 autosexual intergender greygender akiosexual bigender demigender demiboy demigirl transmasculine transfeminine genderfaun demifaun genderfae demifae neutrois biromantic1 biromantic2 autoromantic boyflux2 finsexual unlabeled1 unlabeled2 pangender gendernonconforming1 gendernonconforming2 femboy tomboy gendervoid voidgirl voidboy beiyang burger)/' \
|
'n/-p/(rainbow transgender nonbinary agender queer genderfluid bisexual pansexual polysexual omnisexual omniromantic gay-men lesbian abrosexual asexual aromantic aroace1 aroace2 aroace3 autosexual intergender greygender akiosexual bigender demigender demiboy demigirl transmasculine transfeminine genderfaun demifaun genderfae demifae neutrois biromantic1 biromantic2 autoromantic boyflux2 finsexual unlabeled1 unlabeled2 pangender gendernonconforming1 gendernonconforming2 femboy tomboy gendervoid voidgirl voidboy beiyang burger)/' \
|
||||||
'n/--preset/(rainbow transgender nonbinary agender queer genderfluid bisexual pansexual polysexual omnisexual omniromantic gay-men lesbian abrosexual asexual aromantic aroace1 aroace2 aroace3 autosexual intergender greygender akiosexual bigender demigender demiboy demigirl transmasculine transfeminine genderfaun demifaun genderfae demifae neutrois biromantic1 biromantic2 autoromantic boyflux2 finsexual unlabeled1 unlabeled2 pangender gendernonconforming1 gendernonconforming2 femboy tomboy gendervoid voidgirl voidboy beiyang burger)/' \
|
'n/--preset/(rainbow transgender nonbinary agender queer genderfluid bisexual pansexual polysexual omnisexual omniromantic gay-men lesbian abrosexual asexual aromantic aroace1 aroace2 aroace3 autosexual intergender greygender akiosexual bigender demigender demiboy demigirl transmasculine transfeminine genderfaun demifaun genderfae demifae neutrois biromantic1 biromantic2 autoromantic boyflux2 finsexual unlabeled1 unlabeled2 pangender gendernonconforming1 gendernonconforming2 femboy tomboy gendervoid voidgirl voidboy beiyang burger)/' \
|
||||||
'n/-m/(8bit rgb)/' \
|
'n/-m/(8bit rgb)/' \
|
||||||
|
|
62
hyfetch/scripts/install-autocomplete.sh
Executable file
62
hyfetch/scripts/install-autocomplete.sh
Executable file
|
@ -0,0 +1,62 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Usage: ./install-autocomplete.sh [Uninstall]
|
||||||
|
if [[ "$1" == "uninstall" ]]; then
|
||||||
|
uninstall=true
|
||||||
|
echo -n "Uninstalling "
|
||||||
|
else
|
||||||
|
echo -n "Installing "
|
||||||
|
fi
|
||||||
|
echo "autocomplete scripts for HyFetch..."
|
||||||
|
|
||||||
|
# Stop on error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Obtain path of the current bash script
|
||||||
|
script_path="$(dirname "$(realpath "$0")")"
|
||||||
|
|
||||||
|
# Installing for a specific shell in a specific directory if it exists
|
||||||
|
install-for()
|
||||||
|
{
|
||||||
|
shell=$1
|
||||||
|
dir=$2
|
||||||
|
|
||||||
|
case $shell in
|
||||||
|
bash)
|
||||||
|
filename="hyfetch"
|
||||||
|
;;
|
||||||
|
zsh)
|
||||||
|
filename="_hyfetch"
|
||||||
|
;;
|
||||||
|
csh)
|
||||||
|
filename="hyfetch.completion.csh"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown shell: $shell"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ -d "$dir" ]]; then
|
||||||
|
if [[ "$uninstall" ]]; then
|
||||||
|
rm -f "$dir/$filename"
|
||||||
|
echo "⭐ Uninstalled for $shell in $dir"
|
||||||
|
else
|
||||||
|
cp "$script_path/autocomplete.$shell" "$dir/$filename"
|
||||||
|
echo "⭐ Installed for $shell in $dir"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy files
|
||||||
|
install-for bash /etc/bash_completion.d
|
||||||
|
install-for bash /usr/share/bash-completion/completions
|
||||||
|
|
||||||
|
install-for zsh /usr/share/zsh/functions/Completion/Unix
|
||||||
|
install-for zsh /usr/share/zsh/site-functions
|
||||||
|
install-for zsh /usr/share/zsh-completions
|
||||||
|
install-for zsh /usr/local/share/zsh/site-functions
|
||||||
|
|
||||||
|
install-for csh /etc/profile.d
|
||||||
|
|
||||||
|
echo "Done!"
|
Loading…
Reference in a new issue