Bash completions

This commit is contained in:
Benjamin Sago 2017-05-06 21:56:40 +01:00
parent 956c5b7181
commit ad85f3d023
2 changed files with 41 additions and 1 deletions

5
Vagrantfile vendored
View File

@ -21,7 +21,7 @@ Vagrant.configure(2) do |config|
config.vm.provision :shell, privileged: true, inline: <<-EOF
apt-get install -qq -o=Dpkg::Use-Pty=0 -y \
git cmake curl attr pkg-config libgit2-dev \
fish
fish zsh bash bash-completion
EOF
@ -63,6 +63,9 @@ Vagrant.configure(2) do |config|
# Link the completion files so theyre “installed”.
config.vm.provision :shell, privileged: true, inline: <<-EOF
test -h /etc/bash_completion.d/exa \
|| ln -s /vagrant/contrib/completions.bash /etc/bash_completion.d/exa
test -h /usr/share/zsh/vendor-completions/_exa \
|| ln -s /vagrant/contrib/completions.zsh /usr/share/zsh/vendor-completions/_exa

37
contrib/completions.bash Normal file
View File

@ -0,0 +1,37 @@
_exa()
{
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-'?'|--help|-v|--version)
return
;;
-L|--level)
COMPREPLY=( $( compgen -W '{0..9}' -- "$cur" ) )
return
;;
-s|--sort)
COMPREPLY=( $( compgen -W 'name filename Name Filename size filesize extension Extension modified accessed created none inode --' -- "$cur" ) )
return
;;
-t|--time)
COMPREPLY=( $( compgen -W 'accessed modified created --' -- $cur ) )
return
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
;;
*)
_filedir
;;
esac
} &&
complete -o filenames -o bashdefault -F _exa exa