-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.esrc
More file actions
executable file
·122 lines (106 loc) · 2.48 KB
/
example.esrc
File metadata and controls
executable file
·122 lines (106 loc) · 2.48 KB
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
#!/usr/bin/env es
# mveety's ~/.esrc
#
# I set most of my environment vars in my .login_conf. I don't know
# if linux has anything similar, but if it does you should use that
# instead of your profile or shell dotfiles. It makes life so much easier
# having everything in one central location instead of being strewn about.
# I added the path for linux
# path = (/usr/local/sbin /usr/local/bin /usr/bin /usr/lib/jvm/default/bin /usr/bin/site_perl /usr/bin/vendor_perl /usr/bin/core_perl)
# set up libraries support to make sure it works
corelib = '/usr/local/share/es'
libraries = $home^'/eslib'
import show dirstack lc history string
# get git branch info
fn mv-git-branch {
local(b=<-{git branch '--show-current' >[2=1]}) {
if {~ $b(1) 0} {
result ' ('^$b(2)^')'
} {
result ''
}
}
}
# format path to shorten it (if possible)
fn mv-pathfmt path {
local(homes=(/usr/home /home /export/home)) {
if {~ $username 'root' && ~ $path /root /root/*} {
return '~'^<={~~ $path /root*}
}
match $path (
($homes/$username) {
return '~'
}
($homes/$username/*) {
return '~/'^<={~~ $path $homes/$username/*}
}
($homes/*) {
return '~'^<={~~ $path $homes/*}
}
(/root) {
return '~root'
}
(/root/*) {
return '~root/'^<={~~ $path /root/*}
}
* {
return $path
}
)
}
}
# replacement for hg incoming/outgoing
fn egit command branch {
branch = <={ if {~ $#branch 0} {
result `{git rev-parse --abbrev-ref HEAD}
} {
result $branch
}
}
if {~ $command 'outgoing'} {
git fetch origin
git log 'origin/'^$branch^'..'^$branch
} {~ $command 'incoming'} {
git fetch origin
git log $branch^'..origin/'^$branch
} {
throw usage egit 'usage: egit [outgoing|incoming]'
}
}
# easy switching between prompts
fn set-prompt pname {
if {~ $#pname 0} {
throw usage set-prompt $0^' [prompt-name]'
}
if {~ $#('fn-'^$pname^'-prompt') 0} {
throw error set-prompt 'prompt '^$pname^' does not exist'
} {
fn-%prompt = $('fn-'^$pname^'-prompt')
result <=true
}
}
## prompt options
# pretty prompt
fn mveety-prompt {
prompt = ($hostname^':'^<={mv-pathfmt $cwd}^<={mv-git-branch}^' % ' '_% ')
}
fn path-prompt {
prompt = ($cwd^'% ' '_% ')
}
fn pathfmt-prompt {
prompt = (<={mv-pathfmt $cwd}^'% ' '_% ')
}
fn hostname-prompt {
prompt = ($hostname^'% ' '_% ')
}
## hooks
fn %cdhook {
cwd = `{pwd}
}
## configuration
history = '/home/mveety/.history'
histmax = 10
hostname=`{uname -n}
username=`{whoami}
cwd=`{pwd}
set-prompt mveety