Przeglądaj źródła

Bash completions

Benjamin Sago 8 lat temu
rodzic
commit
ad85f3d023
2 zmienionych plików z 41 dodań i 1 usunięć
  1. 4 1
      Vagrantfile
  2. 37 0
      contrib/completions.bash

+ 4 - 1
Vagrantfile

@@ -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 they’re “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 - 0
contrib/completions.bash

@@ -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