-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path05_editor
56 lines (48 loc) · 1.47 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
export EDITOR
export CVSEDITOR
export GIT_EDITOR
# Define an order or preference for text editors
local editors
editors=(vim mate mvim gvim nano pico)
# Look for the first of these editors which exists
for editor ($editors) {
if [[ -x $(which $editor) ]]; then
EDITOR=$editor
break
fi
}
# Some editors need specific arguments for VCS
if [[ $EDITOR == 'mvim' || $EDITOR == 'gvim' ]]; then
export CVSEDITOR="$EDITOR -f" # Don't fork.
export GIT_EDITOR="$EDITOR -f" # Don't fork.
fi
# Print a warning if there's still no editor set.
[[ -z $EDITOR ]] && print 'No editor set.'
# TextMate specific stuff:
if [[ $EDITOR == 'mate' && -x $(which bundle) && -n $(bundle) && $? = 0 && -z $SSH_CLIENT ]]; then
EDITOR="mate -w"
# Useful functions for bundle development
function reload_textmate(){
osascript -e 'tell app "TextMate" to reload bundles'
}
function bundle () {
cd "$HOME/Library/Application Support/TextMate/Bundles/$1.tmbundle"
}
_bundle() {
bundle_path="$HOME/Library/Application Support/TextMate/Bundles"
compadd $(print -l $bundle_path/*.tmbundle(:t:r))
}
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