forked from mattfoster/zshkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
05_editor
40 lines (35 loc) · 808 Bytes
/
05_editor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env zsh
export EDITOR
function not_run_from_ssh () {
ps x|grep "${PPID}.*sshd"|grep -v grep
echo $?
}
if [[ -x `which mvim` && $(not_run_from_ssh) = 1 ]]; then
EDITOR=mvim
alias vi=mvim
elif [[ -x `which gvim` ]]; then
EDITOR=gvim
elif [[ -x `which vim` ]]; then
EDITOR=vim
elif [[ -x `which vi` ]]; then
EDITOR=vi
elif [[ -x `which nano` ]]; then
EDITOR=nano
elif [[ -x `which pico` ]]; then
EDITOR=pico
else
EDITOR=vi
fi
# Set EDITOR as default for plaintext stuff
for s in txt tex c cc cxx cpp gp m md markdown otl; do
alias -s $s=$EDITOR
done
# Abuse the "open" command on OS X
if [[ $OSTYPE[1,6] == "darwin" ]]; then
for s in mp3 wav aac \
ogg avi mp4 m4v mov qt mpg mpeg \
jpg jpeg png psd bmp gif tif tiff \
eps ps pdf html dmg; do
alias -s $s=open
done
fi