From: Jer Noble Date: Wed, 10 Apr 2013 01:04:41 +0000 (-0700) Subject: Added has() function; made EDITOR variables dependent on whether terminal is remote. X-Git-Url: http://id.pley.net/dotfiles.git/commitdiff_plain/5a2aa4d6a19afcbc19ced19b67d2ad4f99b9de5a?ds=inline Added has() function; made EDITOR variables dependent on whether terminal is remote. --- diff --git a/zsh_aliases b/zsh_aliases index dae48a8..f330702 100644 --- a/zsh_aliases +++ b/zsh_aliases @@ -51,8 +51,18 @@ function viw () { vi $(which $1); } function toss () { mv -f $@ ~/.trashcan; } function xcopy () { tar cvf - -C $1 $1/* | tar xvf - -C $2; } function checkdns () { ping $( grep nameserver /etc/resolv.conf | awk '{print $2}' | head -1); } +function has () { + which $1 &> /dev/null + if [[ $? -eq 0 ]]; then + echo 'yes' + return 0 + else + echo 'no' + return 1 + fi +} -if [[ $(which pidof &> /dev/null; echo $?) -eq 1 ]]; then +if [[ $( has pidof ) == 'no' ]]; then function pidof () { ps -e -o pid,comm | grep "$1" | awk '{print $1}'; } fi diff --git a/zsh_webkit_login b/zsh_webkit_login index 6dc4657..589a236 100644 --- a/zsh_webkit_login +++ b/zsh_webkit_login @@ -20,4 +20,22 @@ _switchto() { _arguments '1:dir:_webkit_dirs' } compdef _switchto switchto +if [[ $( has bbedit ) == 'yes' ]]; then + export GUI_EDITOR="bbedit -w" +elif [[ $( has mate_wait ) == 'yes' ]]; then + export GUI_EDITOR="mate_wait" +else + export GUI_EDITOR="vim" +fi + +if [[ -z "$SSH_TTY" ]]; then + export EDITOR="$GUI_EDITOR" + export SVN_LOG_EDITOR="$GUI_EDITOR" + export GIT_SEQUENCE_EDITOR="$GUI_EDITOR" +else + export EDITOR=vim + export SVN_LOG_EDITOR=vim + export GIT_SEQUENCE_EDITOR=vim +fi + switchto git