aboutsummaryrefslogtreecommitdiffstats
path: root/.tcshrc
blob: ac82e6d6f842397c86f55bf54f3d8fc24db4cdae (plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#####################################################################
### /etc/csh.cshrc
### $HOME/.tcshrc
### LY4ever
### June 30, 2011


### "root" environment (basic) ######################################
if ($LOGNAME == "root") then
    set -f path = ( $path /sbin )
    set -f path = ( $path /usr/sbin )
    set -l path = ( $path /usr/local/sbin )
endif

### "ly" environment (basic) ########################################
if ($LOGNAME == "ly") then
    set -f path = ( ~/bin $path )
    set -f path = ( $path /sbin )
    set -f path = ( $path /usr/sbin )
    set -l path = ( $path /usr/local/sbin )
endif

### "user" + "root" environment (basic) #############################
set -f path = ( $path /bin )
set -f path = ( $path /usr/bin )
set -f path = ( $path /usr/local/bin )

### "user" + "root" environment (misc) ##############################
set -l path = ( $path /usr/games )


### Environment settings ############################################
# colors for 'ls'
setenv LSCOLORS     ExGxFxdxCxegedabagExEx
setenv CLICOLOR     yes
# colors for 'grep'
setenv GREP_OPTIONS '--color=auto'

# locale
setenv LANG         en_US.UTF-8
setenv LC_CTYPE     zh_CN.UTF-8
setenv LC_COLLATE   C

# settings for 'fcitx'
setenv XMODIFIERS       @im=fcitx
setenv QT_IM_MODULE     xim
setenv GTK_IM_MODULE    xim

# Misc
setenv PAGER less
setenv LESS '-ceiMs'
setenv EDITOR vim
setenv VISUAL vim


#####################################################################
###  skip remaining setup if not an interactive shell
if ($?USER == 0 || $?prompt == 0) exit


### color code ######################################################
# 1 for brighter colors
# 4 for underlined text
# 5 for flashing text
# 30 for black foreground
# 31 for red foreground
# 32 for green foreground
# 33 for yellow (or brown) foreground
# 34 for blue foreground
# 35 for purple foreground
# 36 for cyan foreground
# 37 for white (or gray) foreground
# 40 for black background
# 41 for red background
# 42 for green background
# 43 for yellow (or brown) background
# 44 for blue background
# 45 for purple background
# 46 for cyan background
# 47 for white (or gray) background

#set cr = "%{\e[31m%}" # red
#set cg = "%{\e[32m%}" # green
#set cy = "%{\e[33m%}" # yellow
#set c0 = "%{\e[0m%}"  # recovery

# prompt
#set promptchars = ">#"
#if ( $?prompt ) then
#    if ( "$uid" == "0" ) then
#        set prompt = "%B$cr%n%b$c0@$cy%m$cg.%? %B$cr%#%b "
#    else
#        set prompt = "%B$cg%n%b$c0@$cy%m$c0.%? %B$cg%#%b "
#    endif
#endif
#set rprompt = "%~"


### prompt ##########################################################
# Source: "UNIX Power Tools" from O'Reilly
# Note from Tim Cera (timcera@sourceforge.net).
set prompt='\
%B%n%b@%U%m%u %B%S%/%s%b\
%B%#%b '
# Prompt used when waiting for stufffor 'for' or 'while'...
set prompt2="%R? "
# Prompt used when correcting.
set prompt3="CORRECT> %B%R%b (y|n|e)? "


### bindkey #########################################################
bindkey '\e[1~' beginning-of-line        # Home
bindkey '\e[3~' delete-char              # Delete
bindkey '\e[4~' end-of-line              # End
bindkey "^W"    backward-delete-word     # Delete
bindkey -k up   history-search-backward  # PageUp
bindkey -k down history-search-forward   # PageDown
# vi-style key bindings
#bindkey -v


### Tcsh settings ###################################################
set ignoreeof
set listlinks
set nobeep
set noclobber

set history = 512
set savehist = 512

# Watch any(1) other users every 0 seconds from any(2) console, 
set watch=(0 any any)

# Format of output string when someone logins or logouts
set who="%n has %a %l from %M."

set inputmode=insert

set autolist
set autocorrect

# Use the history of commands to aid expansion.
set autoexpand

set complete=enhance
set correct=cmd

#set autologout = (30 5)
unset autologout

# Symbolic links are expanded to their true values : chase
# (possible values 'chase' 'ignore' 'expand')
set symlinks=chase

# After a 'Ctrl-Z', list all the jobs
set listjobs

# If the exit value is non-zero, print it
set printexitvalue

# Ask for confirmation when 'rm *'
set rmstar

# Files that are to be ignored from completion.
set fignore=(.o)

set time=(8 "\
Time spent in user mode   (CPU seconds) : %Us\
Time spent in kernel mode (CPU seconds) : %Ss\
Total time                              : %Es\
CPU utilisation (percentage)            : %P\
Times the process was swapped           : %W\
Times of major page faults              : %F\
Times of minor page faults              : %R")

# Before printing prompt after a command, do
#alias precmd date

# Other values are bsd, sysv, etc.
# This way, both 'set -n' and set '\003' styles will work.
set echo_style=both


### Tcsh aliases ####################################################
# for a better habit
#alias rm 'rm -iv'
#alias mv 'mv -iv'
#alias cp 'cp -iv'

alias md    'mkdir -v -p'
alias rd    'rmdir -v'

alias today "date '+%d%h%y'"
alias mess  'clear ; tail -f /var/log/messages'

alias x     'exit'
alias ff    'find . -name $*'

#alias .     'pwd'
alias ..    'cd ..'
alias ../   'cd ../'
alias ...   'cd ../..'
alias .../  'cd ../../'
alias -     'cd -'
alias /     'cd /'
alias ls    'ls -F --color=auto'
alias la    'ls -AF'
alias lla   'ls -AlF'
alias ll    'ls -Flh'
alias lld   'ls -dlh'

alias df    'df -haT'
#alias grep  'grep -i'

# show
alias show-ifstat    'systat -ifstat'      # net interface
alias show-geom      'gstat'               # I/O state
alias show-thermal   'sysctl dev.acpi_ibm.0.thermal'
alias show-cpufreq   'sysctl dev.cpu.0.freq'
alias show-cpulevels 'sysctl dev.cpu.0.freq_levels'
alias show-battery   'sysctl hw.acpi.battery.life && sysctl hw.acpi.battery.time'
alias show-alldep    'make all-depends-list'         # exec under 'ports' dirs
alias show-dep       'portmaster --show-work ./ | sort'

# misc
alias v     'vim'
alias a     'alias'
alias h     'history | less'
alias ox    'oxford'
#alias valgrind-checkmem 'valgrind --tool=memcheck --leak-check=full'  # check 'memory leak'

# aliases for typos
alias maek  'make'
alias alais 'alias'

# for security
alias del   'mv \!* ~/tmp'

### Tcsh completion #################################################
# ~/.tcsh_completion dir
if ( -d ~/.tcsh/completion ) then
    foreach tcsh_comp ( ~/.tcsh/completion/*.tcsh )
        source $tcsh_comp
    end
endif
unset tcsh_comp


### Misc ############################################################
### cdargs
# Just the basic cdargs functionality for tcshell
alias cv 'cdargs \!* && cd `cat $HOME/.cdargsresult`'
# add current directory with description:
alias ca 'cdargs --add=:\!*":"$cwd'
complete cv 'n@*@`cat -s ~/.cdargs | sed -e "s/ .*//"`@'


### Tcsh special aliases ############################################
## tcsh  period
# Every # seconds, do 'command'.
# set tperiod = 2
# alias periodic 'tput bel'
#unset tperiod
#unalias periodic

### ly4ever local ###################################################
## local settings
if ( -e ~/.tcshrc.local ) then
    source ~/.tcshrc.local
endif

## tcsh sched
# sched +8:00 set prompt='Has trabajado mucho. Llama la novia\! :> '

## run commands
#fortune -s | cowsay -f ~/.littleprince.cow -W 48
calendar
date