Skip to content

Commit

Permalink
Merge pull request #3 from stateful/Completions
Browse files Browse the repository at this point in the history
added completion for fish,zsh,bash, pwsh
  • Loading branch information
edeediong authored Oct 10, 2023
2 parents 70e8740 + 0e03d61 commit ef00e41
Showing 1 changed file with 42 additions and 9 deletions.
51 changes: 42 additions & 9 deletions src/runme/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,49 @@ $nanolayer_location \

# Need a new shell to pick up NVM paths
bash -i << EOF
if [ "$COMPLETIONS" = "true" ]; then {
# runme bash completion
mkdir -p /etc/bash_completion.d
runme completion bash > /etc/bash_completion.d/runme
# runme zsh completion
if [ -e "/usr/share/zsh/vendor-completions" ]; then
runme completion zsh > /usr/share/zsh/vendor-completions/_runme
if [ "$COMPLETIONS" = "true" ]; then
# Check if the current shell is Bash
if [ "$(basename $SHELL)" = "bash" ]; then
# runme bash completion
mkdir -p /etc/bash_completion.d
runme completion bash > /etc/bash_completion.d/runme
source /etc/bash_completion.d/runme
fi
} fi
# Check if the current shell is Zsh
if [ "$(basename $SHELL)" = "zsh" ]; then
# runme zsh completion
ZSH_COMPLETIONS_DIR="/usr/share/zsh/site-functions/"
mkdir -p $ZSH_COMPLETIONS_DIR
runme completion zsh > "$ZSH_COMPLETIONS_DIR/_runme"
source $ZSH_COMPLETIONS_DIR/_runme
fi
# Check if the current shell is fish
if [ "$(basename $SHELL)" = "fish" ]; then
# runme fish completion
FISH_COMPLETIONS_DIR="/usr/share/fish/vendor_completions.d"
mkdir -p $FISH_COMPLETIONS_DIR
runme completion fish > "$FISH_COMPLETIONS_DIR/_runme"
source $FISH_COMPLETIONS_DIR/_runme
fi
# Check if the current shell is PowerShell
if [ "$(basename $SHELL)" = "pwsh" ]; then
# Enable Powershell tab-completion
Set-PSReadlineKeyHandler -Key Tab -Function Complete
mkdir -p $FISH_COMPLETIONS_DIR
runme completion fish > "$FISH_COMPLETIONS_DIR/_runme"
source $FISH_COMPLETIONS_DIR/_runme
fi
fi
EOF

echo 'Done!'

0 comments on commit ef00e41

Please sign in to comment.