Created
April 11, 2014 09:55
-
-
Save rejuvyesh/10454832 to your computer and use it in GitHub Desktop.
script to run avaialble editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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