-
Notifications
You must be signed in to change notification settings - Fork 58
/
config.fish
132 lines (104 loc) · 3.22 KB
/
config.fish
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
if status --is-login
for p in /usr/bin /usr/local/bin /opt/local/bin /usr/local/mysql/bin /opt/local/lib/postgresql83/bin ~/bin ~/.config/fish/bin
if test -d $p
set PATH $p $PATH
end
end
end
set fish_greeting ""
set -x CLICOLOR 1
function parse_git_branch
sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
end
function parse_git_tag
git describe --tags --always ^/dev/null
end
function parse_git_tag_or_branch
if [ (parse_git_branch) != "(no branch)" ]
parse_git_branch
else
parse_git_tag
end
end
function git_parse_ahead_of_remote
git status ^/dev/null | grep 'Your branch is ahead of' | sed -e 's/# Your branch is ahead of .* by \(.*\) commit.*/\1/g'
end
function is_git
git status >/dev/null ^&1
return $status
end
function parse_svn_tag_or_branch
sh -c 'svn info | grep "^URL:" | egrep -o "(tags|branches)/[^/]+|trunk" | egrep -o "[^/]+$"'
end
function parse_svn_revision
sh -c 'svn info 2> /dev/null' | sed -n '/^Revision/p' | sed -e 's/^Revision: \(.*\)/\1/'
end
function is_svn
svnversion | egrep -vq '^(Unversioned directory|exported)'
return $status
end
function fish_prompt -d "Write out the prompt"
printf '%s%s@%s%s' (set_color brown) (whoami) (hostname|cut -d . -f 1) (set_color normal)
# Color writeable dirs green, read-only dirs red
if test -w "."
printf ' %s%s' (set_color green) (prompt_pwd)
else
printf ' %s%s' (set_color red) (prompt_pwd)
end
# Print subversion tag or branch
if is_svn
printf ' %s%s%s' (set_color normal) (set_color blue) (parse_svn_tag_or_branch)
end
# Print subversion revision
if is_svn
printf '%s%s@%s' (set_color normal) (set_color blue) (parse_svn_revision)
end
# Print git tag or branch
if is_git
printf ' %s%s/%s' (set_color normal) (set_color blue) (parse_git_tag_or_branch)
set git_ahead_of_remote (git_parse_ahead_of_remote)
if [ -n "$git_ahead_of_remote" -a "$git_ahead_of_remote" != "0" ]
printf ' +%s' (git_parse_ahead_of_remote)
end
end
printf '%s> ' (set_color normal)
end
bind \cr "rake"
function ss -d "Run the script/server"
script/server
end
function sc -d "Run the Rails console"
script/console
end
if test -d "/opt/java"
set -x JAVA_HOME "/opt/java"
end
# yarrr, add /var/lib/gems/1.8/bin to path so gems installed by the retarded ubuntu rubygems package are on the path
set CUSTOM_GEM_PATH "/var/lib/gems/1.8/bin"
if test -d $CUSTOM_GEM_PATH
set -x PATH $PATH "/var/lib/gems/1.8/bin"
end
# Load custom settings for current hostname
set HOST_SPECIFIC_FILE ~/.config/fish/(hostname).fish
if test -f $HOST_SPECIFIC_FILE
. $HOST_SPECIFIC_FILE
else
echo Creating host specific file: $HOST_SPECIFIC_FILE
touch $HOST_SPECIFIC_FILE
end
# Load custom settings for current user
set USER_SPECIFIC_FILE ~/.config/fish/(whoami).fish
if test -f $USER_SPECIFIC_FILE
. $USER_SPECIFIC_FILE
else
echo Creating user specific file: $USER_SPECIFIC_FILE
touch $USER_SPECIFIC_FILE
end
# Load custom settings for current OS
set PLATFORM_SPECIFIC_FILE ~/.config/fish/(uname -s).fish
if test -f $PLATFORM_SPECIFIC_FILE
. $PLATFORM_SPECIFIC_FILE
else
echo Creating platform specific file: $PLATFORM_SPECIFIC_FILE
touch $PLATFORM_SPECIFIC_FILE
end