diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2014-10-13 17:43:25 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2014-10-13 17:43:25 +1300 |
commit | daf62af720e66f8059982bf3638d37534aba54aa (patch) | |
tree | 0567470ec0a169850e7585b6b38c3f27a49aa554 /bash/bashrc.d | |
parent | Fix alphabetical order (diff) | |
download | dotfiles-daf62af720e66f8059982bf3638d37534aba54aa.tar.gz dotfiles-daf62af720e66f8059982bf3638d37534aba54aa.zip |
Remove some overzealous command checks
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r-- | bash/bashrc.d/ed.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/ftp.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/git.bash | 7 | ||||
-rw-r--r-- | bash/bashrc.d/gnupg.bash | 11 | ||||
-rw-r--r-- | bash/bashrc.d/make.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/mysql.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/pass.bash | 11 | ||||
-rw-r--r-- | bash/bashrc.d/pwgen.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/ssh.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/tmux.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/vim.bash | 13 |
11 files changed, 18 insertions, 59 deletions
diff --git a/bash/bashrc.d/ed.bash b/bash/bashrc.d/ed.bash index 7cef29e6..1a7a2b63 100644 --- a/bash/bashrc.d/ed.bash +++ b/bash/bashrc.d/ed.bash @@ -1,8 +1,3 @@ -# Bail if no ed(1) -if ! hash ed 2>/dev/null ; then - return -fi - # Add a colon prompt to ed when a command is expected rather than text; makes # it feel a lot more like using ex. Only do this when stdin is a terminal, # however. diff --git a/bash/bashrc.d/ftp.bash b/bash/bashrc.d/ftp.bash index f0fc5aac..e318a1b6 100644 --- a/bash/bashrc.d/ftp.bash +++ b/bash/bashrc.d/ftp.bash @@ -1,8 +1,3 @@ -# Bail if no ftp(1) -if ! hash ftp 2>/dev/null ; then - return -fi - # Completion for ftp with .netrc machines _ftp() { local word=${COMP_WORDS[COMP_CWORD]} diff --git a/bash/bashrc.d/git.bash b/bash/bashrc.d/git.bash index ba45d4ad..76477fa9 100644 --- a/bash/bashrc.d/git.bash +++ b/bash/bashrc.d/git.bash @@ -1,12 +1,7 @@ -# Bail if no git(1) -if ! hash git 2>/dev/null ; then - return -fi - # Completion for git local branch names _git() { - # Bail if not a git repo + # Bail if not a git repo (or no git!) if ! git rev-parse --git-dir >/dev/null 2>&1 ; then return 1 fi diff --git a/bash/bashrc.d/gnupg.bash b/bash/bashrc.d/gnupg.bash index e5962d21..44697f58 100644 --- a/bash/bashrc.d/gnupg.bash +++ b/bash/bashrc.d/gnupg.bash @@ -1,8 +1,3 @@ -# Bail if no gpg(1) -if ! hash gpg 2>/dev/null ; then - return -fi - # Wrapper around gpg(1) to stop ``--batch'' breaking things gpg() { case $* in @@ -19,6 +14,12 @@ gpg() { _gpg() { local word=${COMP_WORDS[COMP_CWORD]} + # Bail if no gpg(1) + if ! hash gpg 2>/dev/null ; then + COMPREPLY=() + return 1 + fi + # Bail if word doesn't start with two dashes if [[ $word != --* ]] ; then COMPREPLY=() diff --git a/bash/bashrc.d/make.bash b/bash/bashrc.d/make.bash index cf10c44a..6e0f4185 100644 --- a/bash/bashrc.d/make.bash +++ b/bash/bashrc.d/make.bash @@ -1,8 +1,3 @@ -# Bail if no make(1) -if ! hash make 2>/dev/null ; then - return -fi - # Completion setup for Make, completing targets _make() { local word=${COMP_WORDS[COMP_CWORD]} diff --git a/bash/bashrc.d/mysql.bash b/bash/bashrc.d/mysql.bash index 24317b24..32eba449 100644 --- a/bash/bashrc.d/mysql.bash +++ b/bash/bashrc.d/mysql.bash @@ -1,8 +1,3 @@ -# Bail if no mysql(1) -if ! hash mysql 2>/dev/null ; then - return -fi - # If a file ~/.mysql/$1.cnf exists, call mysql(1) using that file. Otherwise # just run MySQL with given args. Use restrictive permissions on these files. # Examples: diff --git a/bash/bashrc.d/pass.bash b/bash/bashrc.d/pass.bash index a03b0887..b39608ba 100644 --- a/bash/bashrc.d/pass.bash +++ b/bash/bashrc.d/pass.bash @@ -1,11 +1,12 @@ -# Bail if no pass(1) -if ! hash pass 2>/dev/null ; then - return -fi - # Completion for pass(1), adapted from source package; still needs some tweaking _pass() { + # Bail if no pass(1) + if ! hash pass 2>/dev/null ; then + COMPREPLY=() + return 1 + fi + # Get current word, prefix, and suffix local word=${COMP_WORDS[COMP_CWORD]} local prefix=${PASSWORD_STORE_DIR:-$HOME/.password-store} diff --git a/bash/bashrc.d/pwgen.bash b/bash/bashrc.d/pwgen.bash index df39274f..10cd3a41 100644 --- a/bash/bashrc.d/pwgen.bash +++ b/bash/bashrc.d/pwgen.bash @@ -1,8 +1,3 @@ -# Bail if no pwgen(1) -if ! hash pwgen 2>/dev/null ; then - return -fi - # Set some defaults for pwgen, because its defaults are to give me a long list # of relatively short passwords, when I generally want only one good one pwgen() { diff --git a/bash/bashrc.d/ssh.bash b/bash/bashrc.d/ssh.bash index 452a4c97..0f1a8d65 100644 --- a/bash/bashrc.d/ssh.bash +++ b/bash/bashrc.d/ssh.bash @@ -1,8 +1,3 @@ -# Bail if no ssh(1) -if ! hash ssh 2>/dev/null ; then - return -fi - # Wrap scp to check for missing colons scp() { if (($# >= 2)) && [[ $* != *:* ]] ; then diff --git a/bash/bashrc.d/tmux.bash b/bash/bashrc.d/tmux.bash index 1718b103..200001da 100644 --- a/bash/bashrc.d/tmux.bash +++ b/bash/bashrc.d/tmux.bash @@ -1,8 +1,3 @@ -# Bail if no tmux(1) -if ! hash tmux 2>/dev/null ; then - return -fi - # Attach to existing tmux session rather than create a new one if possible tmux() { diff --git a/bash/bashrc.d/vim.bash b/bash/bashrc.d/vim.bash index e6b8e369..b312591e 100644 --- a/bash/bashrc.d/vim.bash +++ b/bash/bashrc.d/vim.bash @@ -1,10 +1,7 @@ -# Bail if no vim(1) -if ! hash vim 2>/dev/null ; then - return -fi - # If Vim exists on the system, use it instead of ex, vi, and view -alias ex='vim -e' -alias vi='vim' -alias view='vim -R' +if hash vim 2>/dev/null ; then + alias ex='vim -e' + alias vi='vim' + alias view='vim -R' +fi |