diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-10-16 20:58:21 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-10-16 20:58:21 +1300 |
commit | 74b457d9719df8ca810de9cbf964784ccee5b866 (patch) | |
tree | b77c25505788411564ac5aaa9194a22fd781a488 /bash | |
parent | Add completion for pass(1) (diff) | |
download | dotfiles-74b457d9719df8ca810de9cbf964784ccee5b866.tar.gz dotfiles-74b457d9719df8ca810de9cbf964784ccee5b866.zip |
Check for presence of binaries before script setup
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc.d/ed.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/ftp.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/gnupg.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/mysql.bash | 5 | ||||
-rw-r--r-- | bash/bashrc.d/pass.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 | 23 |
8 files changed, 43 insertions, 15 deletions
diff --git a/bash/bashrc.d/ed.bash b/bash/bashrc.d/ed.bash index d4d92158..9f5fb5f2 100644 --- a/bash/bashrc.d/ed.bash +++ b/bash/bashrc.d/ed.bash @@ -1,3 +1,8 @@ +# 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 04518b5f..4d0e89a6 100644 --- a/bash/bashrc.d/ftp.bash +++ b/bash/bashrc.d/ftp.bash @@ -1,3 +1,8 @@ +# 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/gnupg.bash b/bash/bashrc.d/gnupg.bash index 0826be30..3b6f1bde 100644 --- a/bash/bashrc.d/gnupg.bash +++ b/bash/bashrc.d/gnupg.bash @@ -1,3 +1,8 @@ +# Bail if no gpg(1) +if ! hash gpg 2>/dev/null; then + return +fi + # Completion for gpg with long options _gpg() { local word=${COMP_WORDS[COMP_CWORD]} diff --git a/bash/bashrc.d/mysql.bash b/bash/bashrc.d/mysql.bash index 391c130d..fb1f7126 100644 --- a/bash/bashrc.d/mysql.bash +++ b/bash/bashrc.d/mysql.bash @@ -1,3 +1,8 @@ +# 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 05e3032b..2cd25cb9 100644 --- a/bash/bashrc.d/pass.bash +++ b/bash/bashrc.d/pass.bash @@ -1,3 +1,8 @@ +# 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() { diff --git a/bash/bashrc.d/ssh.bash b/bash/bashrc.d/ssh.bash index 9eaf4389..da38abce 100644 --- a/bash/bashrc.d/ssh.bash +++ b/bash/bashrc.d/ssh.bash @@ -1,3 +1,8 @@ +# Bail if no ssh(1) +if ! hash ssh 2>/dev/null; then + return +fi + # Completion for ssh/sftp/ssh-copy-id with config hostnames _ssh() { local word=${COMP_WORDS[COMP_CWORD]} diff --git a/bash/bashrc.d/tmux.bash b/bash/bashrc.d/tmux.bash index f4b42081..e7aaa826 100644 --- a/bash/bashrc.d/tmux.bash +++ b/bash/bashrc.d/tmux.bash @@ -1,3 +1,8 @@ +# 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 bcdcd86d..f6109602 100644 --- a/bash/bashrc.d/vim.bash +++ b/bash/bashrc.d/vim.bash @@ -1,23 +1,16 @@ +# 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 ex() { - if hash vim 2>/dev/null; then - command vim -e "$@" - else - command ex "$@" - fi + command vim -e "$@" } vi() { - if hash vim 2>/dev/null; then - command vim "$@" - else - command vi "$@" - fi + command vim "$@" } view() { - if hash vim 2>/dev/null; then - command vim -R "$@" - else - command view "$@" - fi + command vim -R "$@" } |