Skip to content

Instantly share code, notes, and snippets.

@rejuvyesh
Created April 11, 2014 09:55
Show Gist options
  • Save rejuvyesh/10454832 to your computer and use it in GitHub Desktop.
Save rejuvyesh/10454832 to your computer and use it in GitHub Desktop.
script to run avaialble editor
#!/bin/zsh
eclient=$(which emacsclient)
emacs=$(which emacs)
vim=$(which vim)
name=${0:t}
if [[ $name == "emacs-gui" ]]; then
argclient=("-c" "-n")
argemacs=""
elif [[ $name == "emacs-gui-wait" ]]; then
argclient=("-c")
argemacs=""
else
argclient="-nw"
argemacs="-nw"
fi
# use the daemon if it exists, but fall back on a stand-alone emacs, or vim/vi on crappy systems
if [[ -e $eclient ]]; then
if [[ -e $emacs ]]; then
emacsclient $argclient --alternate-editor="emacs $argemacs" $*
else
if [[ -e $vim ]]; then
emacsclient $argclient --alternate-editor='vim' $*
else
emacsclient $argclient --alternate-editor='vi' $*
fi
fi
else
if [[ -e $emacs ]]; then
emacs $argemacs $* &!
else
if [[ -e $vim ]]; then
vim $*
else
vi $*
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment