From 9e77e83d7f5437eaf3a2bd2126f6931af6169646 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sat, 21 Apr 2018 17:18:43 +0100 Subject: [PATCH] Only add aliases when the target command exists Previously aliases for commands were added without checking if the command being aliased existed first, this is now not the case. --- zshrc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/zshrc b/zshrc index 1cb269a..abf5786 100644 --- a/zshrc +++ b/zshrc @@ -130,20 +130,27 @@ fi # Aliases alias grep='grep --color=always' -alias cninja='cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMNADS=ON' -alias ssh='TERM=xterm-256color ssh' +which cmake &> /dev/null && \ + alias cninja='cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMNADS=ON' +which ssh &> /dev/null && \ + alias ssh='TERM=xterm-256color ssh' case `uname` in Linux) [ "$TMUX" = "" ] && \ - alias cls="printf '\ec'" || alias cls="clear && printf '\e[3J'" + alias cls="printf '\ec'" || \ + alias cls="clear && printf '\e[3J'" alias ls='ls -F --color=auto' - alias debug='cgdb --args' + which cgdb &> /dev/null && \ + alias debug='cgdb --args' || \ + which gdb &> /dev/null && \ + alias debug='gdb --args' ;; Darwin) alias cls="clear && printf '\e[3J'" alias ls='ls -GFh' - alias debug='lldb --' + which lldb &> /dev/null && \ + alias debug='lldb --' ;; esac