-
Notifications
You must be signed in to change notification settings - Fork 13
/
.zshrc
executable file
·1184 lines (916 loc) · 25.2 KB
/
.zshrc
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/zsh
#
# .zshrc
# for zsh 3.1.6 and newer (may work OK with earlier versions)
#
# by Adam Spiers <[email protected]>
#
# Best viewed in emacs folding mode (folding.el).
# (That's what all the # {{{ and # }}} are for.)
#
# $Id$
#
[ -n "$INHERIT_ENV" ] && return 0
# {{{ To do list
#
# - du1
# - Do safes?kill(all)? functions
#
# }}}
sh_load_status .zshrc
# {{{ What version are we running?
if ! (( $+ZSH_VERSION_TYPE )); then
if [[ $ZSH_VERSION == 3.0.<->* ]]; then ZSH_STABLE_VERSION=yes; fi
if [[ $ZSH_VERSION == 3.1.<->* ]]; then ZSH_DEVEL_VERSION=yes; fi
ZSH_VERSION_TYPE=old
if [[ $ZSH_VERSION == 3.1.<6->* ||
$ZSH_VERSION == 3.<2->.<->* ||
$ZSH_VERSION == 4.<->* ]]
then
ZSH_VERSION_TYPE=new
fi
fi
# }}}
# {{{ Profiling
[[ -n "$ZSH_PROFILE_RC" ]] && which zmodload >&/dev/null && zmodload zsh/zprof
# }}}
# {{{ Options
sh_load_status 'setting options'
setopt \
NO_all_export \
always_last_prompt \
NO_always_to_end \
append_history \
auto_cd \
auto_list \
auto_menu \
NO_auto_name_dirs \
auto_param_keys \
auto_param_slash \
auto_pushd \
auto_remove_slash \
NO_auto_resume \
bad_pattern \
bang_hist \
NO_beep \
NO_brace_ccl \
correct_all \
NO_bsd_echo \
cdable_vars \
NO_chase_links \
NO_clobber \
complete_aliases \
complete_in_word \
NO_correct \
correct_all \
csh_junkie_history \
NO_csh_junkie_loops \
NO_csh_junkie_quotes \
NO_csh_null_glob \
equals \
extended_glob \
extended_history \
function_argzero \
glob \
NO_glob_assign \
glob_complete \
NO_glob_dots \
glob_subst \
NO_hash_cmds \
hash_dirs \
hash_list_all \
hist_allow_clobber \
hist_beep \
hist_ignore_dups \
hist_ignore_space \
NO_hist_no_store \
hist_verify \
NO_hup \
NO_ignore_braces \
NO_ignore_eof \
interactive_comments \
NO_ksh_glob \
NO_list_ambiguous \
NO_list_beep \
list_types \
long_list_jobs \
magic_equal_subst \
NO_mail_warning \
NO_mark_dirs \
NO_menu_complete \
multios \
NO_nomatch \
notify \
NO_null_glob \
numeric_glob_sort \
NO_overstrike \
path_dirs \
posix_builtins \
NO_print_exit_value \
NO_prompt_cr \
prompt_subst \
pushd_ignore_dups \
NO_pushd_minus \
pushd_silent \
pushd_to_home \
rc_expand_param \
NO_rc_quotes \
NO_rm_star_silent \
NO_sh_file_expansion \
sh_option_letters \
short_loops \
sh_word_split \
NO_single_line_zle \
NO_sun_keyboard_hack \
unset \
NO_verbose \
zle
if [[ $ZSH_VERSION_TYPE == 'new' ]]; then
setopt \
NO_hist_expire_dups_first \
hist_find_no_dups \
NO_hist_ignore_all_dups \
NO_hist_no_functions \
NO_hist_save_no_dups \
inc_append_history \
list_packed \
NO_rm_star_wait
fi
if [[ $ZSH_VERSION == 3.0.<6->* || $ZSH_VERSION_TYPE == 'new' ]]; then
setopt \
hist_reduce_blanks
fi
# }}}
# {{{ Environment
sh_load_status 'setting environment'
# {{{ INFOPATH
[[ "$ZSH_VERSION_TYPE" == 'old' ]] || typeset -T INFOPATH infopath
typeset -U infopath # no duplicates
export INFOPATH
infopath=(
~/{share/,}info(N)
/usr/{share/,}info(N)
$infopath
)
# }}}
# {{{ MANPATH
case "$OSTYPE" in
linux*)
# Don't need to do anything through the cunningness
# of AUTOPATH in /etc/manpath.config!
;;
*)
echo "Not Linux? really?" >&2
;;
esac
# Add extra paths to path determined by /etc/man.config
MANPATH="`MANPATH= manpath`"
manpath=(
$ZDOTDIR/share/[m]an(N)
"$manpath[@]"
)
# }}}
# {{{ LANG
# Eterm sucks
if [[ "$LANG" == *UTF-8 ]] && grep Eterm /proc/$PPID/cmdline >&/dev/null; then
LANG="${LANG%.UTF-8}"
fi
# }}}
# Variables used by zsh
# {{{ Choose word delimiter characters in line editor
# The manual defines WORDCHARS as "a list of non-alphanumeric
# characters considered part of a word by the line editor."
# Nevertheless the effect is not intuitive and best understood by
# experimenting with the value.
WORDCHARS='>~'
# }}}
# {{{ Save a large history
HISTFILE=~/.zshhistory
HISTSIZE=10000
SAVEHIST=10000
# }}}
# {{{ Maximum size of completion listing
#LISTMAX=0 # Only ask if line would scroll off screen
LISTMAX=1000 # "Never" ask
# }}}
# {{{ Watching for other users
LOGCHECK=60
WATCHFMT="[%B%t%b] %B%n%b has %a %B%l%b from %B%M%b"
# }}}
# {{{ Auto logout
# This ancient code is from an era where dinosaurs roamed the earth
# and we all shared computers or even just dumb terminals in a
# computer lab with no screen-lock functionality. These days we can
# protect sessions with biometrics etc. so no need for auto-logout of
# terminals.
#TMOUT=1800
#TRAPALRM () {
# clear
# echo Inactivity timeout on $TTY
# echo
# vlock -c
# echo
# echo Terminal unlocked. [ Press Enter ]
#}
# Don't always autologout
# if [[ "${TERM}" == ([Ex]term*|rxvt*|dtterm|screen*|tmux*) ]]; then
# unset TMOUT
# fi
# }}}
# }}}
# {{{ Prompts
# Load the theme-able prompt system and use it to set a prompt.
# Probably only suitable for a dark background terminal.
local _find_promptinit
_find_promptinit=( $^fpath/promptinit(N) )
if (( $#_find_promptinit >= 1 )) && [[ -r $_find_promptinit[1] ]]; then
sh_load_status 'prompt system'
autoload -U promptinit
promptinit
PS4="trace %N:%i> "
#RPS1="$bold_colour$bg_red $reset_colour"
# Default prompt style
adam2_colors=( white cyan cyan green )
if [[ -r $zdotdir/.zsh_prompt ]]; then
. $zdotdir/.zsh_prompt
fi
if [[ -r /proc/$PPID/cmdline ]] &&
egrep -q 'watchlogs|kates|nexus|vga' /proc/$PPID/cmdline;
then
# probably OK for fancy graphic prompt
if [[ "`prompt -h adam2`" == *8bit* ]]; then
prompt adam2 8bit $adam2_colors
else
prompt adam2 $adam2_colors
fi
else
if [[ "`prompt -h adam2`" == *plain* ]]; then
prompt adam2 plain $adam2_colors
else
prompt adam2 $adam2_colors
fi
fi
# TopGun ssh for Palm
case "$TERM" in
tgtelnet) prompt off ;;
dumb)
# Make sure emacs tramp.el doesn't hang.
# The default value of tramp-shell-prompt-regexp gets confused
# by CR carriage return characters unless you change the first
# ^ to \\(^|^M\\) (N.B. ^M would need to be the raw character
# in that). But instead we can just stop zsh producing them.
# Note that zsh's 'off' prompt theme's prompt_opts causes
# prompt_cr to be enabled.
#prompt off
#setopt no_prompt_cr
# Or we can make our own "theme" right here:
functions precmd >/dev/null && unfunction precmd
functions preexec >/dev/null && unfunction preexec
setopt no_prompt_cr prompt_subst no_prompt_bang prompt_percent
PS1="[%n@%m %1~]\$ "
PS2="> "
# http://www.emacswiki.org/emacs/TrampMode#toc3 suggests these too
# but I don't seem to need them:
#unsetopt zle
#unsetopt prompt_subst
;;
esac
else
PS1='%n@%m %B%3~%b %# '
fi
# }}}
# {{{ Completions
sh_load_status 'completion system'
# {{{ Set up new advanced completion system
if [[ "$ZSH_VERSION_TYPE" == 'new' ]]; then
autoload -Uz compinit
zstyle :compinstall filename '/home/adam/.zshrc'
compinit -u # use with care!!
else
print "\nAdvanced completion system not found; ignoring zstyle settings."
function zstyle { }
function compdef { }
# an antiquated, barebones completion system is better than nowt
which zmodload >&/dev/null && zmodload zsh/compctl
fi
# }}}
# {{{ General completion technique
# zstyle ':completion:*' completer \
# _complete _prefix _approximate:-one _ignored \
# _complete:-extended _approximate:-four
zstyle ':completion:*' completer _complete _prefix _ignored _complete:-extended
zstyle ':completion::prefix-1:*' completer _complete
zstyle ':completion:incremental:*' completer _complete _correct
zstyle ':completion:predict:*' completer _complete
zstyle ':completion:*:approximate-one:*' max-errors 1
zstyle ':completion:*:approximate-four:*' max-errors 4
# e.g. f-1.j<TAB> would complete to foo-123.jpeg
zstyle ':completion:*:complete-extended:*' \
matcher 'r:|[.,_-]=* r:|=*'
# }}}
# {{{ Fancy menu selection when there's ambiguity
#zstyle ':completion:*' menu yes select interactive
#zstyle ':completion:*' menu yes=long select=long interactive
#zstyle ':completion:*' menu yes=10 select=10 interactive
# }}}
# {{{ Completion caching
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
# }}}
# {{{ Expand partial paths
# e.g. /u/s/l/D/fs<TAB> would complete to
# /usr/src/linux/Documentation/fs
zstyle ':completion:*' expand 'yes'
zstyle ':completion:*' squeeze-slashes 'yes'
# }}}
# {{{ Include non-hidden dirs in globbed file completions for certain commands
#zstyle ':completion::complete:*' \
# tag-order 'globbed-files directories' all-files
#zstyle ':completion::complete:*:tar:directories' file-patterns '*~.*(-/)'
# }}}
# {{{ Don't complete backup files (e.g. 'bin/foo~') as executables
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~'
# }}}
# {{{ Don't complete uninteresting users
zstyle ':completion:*:*:*:users' ignored-patterns \
adm amanda apache avahi beaglidx bin cacti canna clamav daemon \
dbus distcache dovecot fax ftp games gdm gkrellmd gopher \
hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \
mailman mailnull mldonkey mysql nagios \
named netdump news nfsnobody nobody nscd ntp nut nx openvpn \
operator pcap postfix postgres privoxy pulse pvm quagga radvd \
rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs
# ... unless we really want to.
zstyle '*' single-ignored show
# }}}
# {{{ Output formatting
# Separate matches into groups
zstyle ':completion:*:matches' group 'yes'
# Describe each match group.
zstyle ':completion:*:descriptions' format "%B---- %d%b"
# Messages/warnings format
zstyle ':completion:*:messages' format '%B%U---- %d%u%b'
zstyle ':completion:*:warnings' format '%B%U---- no match for: %d%u%b'
# Describe options in full
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:options' auto-description '%d'
# }}}
# {{{ Array/association subscripts
# When completing inside array or association subscripts, the array
# elements are more useful than parameters so complete them first:
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# }}}
# {{{ Completion for processes
zstyle ':completion:*:*:*:*:processes' menu yes select
zstyle ':completion:*:*:*:*:processes' force-list always
# }}}
# {{{ Simulate my old dabbrev-expand 3.0.5 patch
zstyle ':completion:*:history-words' stop yes
zstyle ':completion:*:history-words' remove-all-dups yes
zstyle ':completion:*:history-words' list false
zstyle ':completion:*:history-words' menu yes
# }}}
# {{{ Usernames
run_hooks .zsh/users.d
zstyle ':completion:*' users $zsh_users
# }}}
# {{{ Hostnames
if [[ "$ZSH_VERSION_TYPE" == 'new' ]]; then
# Extract hosts from /etc/hosts
# ~~ no glob_subst -> don't treat contents of /etc/hosts like pattern
# (f) shorthand for (ps:\n:) -> split on \n ((p) enables recognition of \n etc.)
# %%\#* -> remove comment lines and trailing comments
# (ps:\t:) -> split on tab
# ##[:blank:]#[^[:blank:]]# -> remove comment lines
: ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
# _ssh_known_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})
else
# Older versions don't like the above cruft
_etc_hosts=()
fi
zsh_hosts=(
"$_etc_hosts[@]"
localhost
)
run_hooks .zsh/hosts.d
zstyle ':completion:*' hosts $zsh_hosts
# }}}
# {{{ (user, host) account pairs
run_hooks .zsh/accounts.d
zstyle ':completion:*:my-accounts' users-hosts "$my_accounts[@]"
zstyle ':completion:*:other-accounts' users-hosts "$other_accounts[@]"
# }}}
# {{{ pdf
compdef _pdf pdf
# }}}
# }}}
# {{{ Aliases and functions
sh_load_status 'aliases and functions'
# {{{ Motion/editing
# {{{ Better word navigation
# Remember, WORDCHARS is defined as a 'list of non-alphanumeric
# characters considered part of a word by the line editor'.
# Elsewhere we set it to the empty string.
_my_extended_wordchars='*?_-.[]~=&;!#$%^(){}<>:@,\\'
_my_extended_wordchars_space="${_my_extended_wordchars} "
_my_extended_wordchars_slash="${_my_extended_wordchars}/"
# is the current position \-quoted ?
is_backslash_quoted () {
test "${BUFFER[$CURSOR-1,CURSOR-1]}" = "\\"
}
unquote-forward-word () {
while is_backslash_quoted
do zle .forward-word
done
}
unquote-backward-word () {
while is_backslash_quoted
do zle .backward-word
done
}
backward-to-space () {
local WORDCHARS="${_my_extended_wordchars_slash}"
zle .backward-word
unquote-backward-word
}
forward-to-space () {
local WORDCHARS="${_my_extended_wordchars_slash}"
zle .forward-word
unquote-forward-word
}
backward-to-/ () {
local WORDCHARS="${_my_extended_wordchars}"
zle .backward-word
unquote-backward-word
}
forward-to-/ () {
local WORDCHARS="${_my_extended_wordchars}"
zle .forward-word
unquote-forward-word
}
# Create new user-defined widgets pointing to eponymous functions.
zle -N backward-to-space
zle -N forward-to-space
zle -N backward-to-/
zle -N forward-to-/
# }}}
zle -N kill-region-or-backward-word
zle -N kill-region-or-backward-big-word
# {{{ kill-big-word
kill-big-word () {
local WORDCHARS="${_my_extended_wordchars_slash}"
zle .kill-word
}
zle -N kill-big-word
# }}}
# {{{ transpose-big-words
# autoloaded
zle -N transpose-big-words
# }}}
# {{{ magic-*
zle -N magic-forward-char
zle -N magic-forward-word
zle -N magic-forward-to-space
zle -N magic-backward-word
zle -N magic-kill-word
zle -N magic-space
# }}}
# {{{ incremental-complete-word
# doesn't work?
zle -N incremental-complete-word
# }}}
# }}}
# {{{ zrecompile
autoload zrecompile
# }}}
# {{{ which/where
# reverse unwanted aliasing of `which' by distribution startup
# files (e.g. /etc/profile.d/which*.sh); zsh's 'which' is perfectly
# good as is.
alias which >&/dev/null && unalias which
# }}}
# {{{ run-help
alias run-help >&/dev/null && unalias run-help
autoload run-help
# }}}
# {{{ zcalc
autoload zcalc
# }}}
# {{{ Restarting zsh or bash; reloading .zshrc or functions
bash () {
NO_SWITCH="yes" command bash "$@"
}
bx () {
PS4="$(. ~/.bashenv.d/PS4; echo $PS4)" bash -x "$@"
}
restart () {
if jobs | grep . >/dev/null; then
echo "Jobs running; won't restart." >&2
jobs -l >&2
else
exec $SHELL $SHELL_ARGS "$@"
fi
}
alias rstt=restart
profile () {
ZSH_PROFILE_RC=1 $SHELL "$@"
}
reload () {
if [[ "$#*" -eq 0 ]]; then
. $zdotdir/.zshrc
else
local fn
for fn in "$@"; do
unfunction $fn
autoload -U $fn
done
fi
}
compdef _functions reload
# }}}
# {{{ ls aliases
if ls -F --color / >&/dev/null; then
LS_OPTS='-F --color'
elif ls -F / >&/dev/null; then
LS_OPTS='-F'
elif ls --color / >&/dev/null; then
LS_OPTS='--color'
fi
# jeez I'm lazy ...
for opts in {,a}{,r}{,t}{,L}{,S}; do
eval "alias l$opts='ls -lh$opts $LS_OPTS'"
eval "alias ll$opts='ls -l$opts $LS_OPTS'"
eval "alias ls$opts='ls ${opts:+-$opts} $LS_OPTS'"
done
alias ld='ls -ldh'
alias sl=ls # often screw this up
# }}}
# {{{ File management/navigation
# {{{ Changing/making/removing directory
alias -g ...=../..
alias -g ....=../../..
alias -g .....=../../../..
alias -g ......=../../../../..
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias cd.....='cd ../../../..'
# blegh
alias ..='cd ..'
alias ../..='cd ../..'
alias ../../..='cd ../../..'
alias ../../../..='cd ../../../..'
alias ../../../../..='cd ../../../../..'
alias cd/='cd /'
alias 1='cd -'
alias 2='cd +2'
alias 3='cd +3'
alias 4='cd +4'
alias 5='cd +5'
alias 6='cd +6'
alias 7='cd +7'
alias 8='cd +8'
alias 9='cd +9'
# Sweet trick from zshwiki.org :-)
cd () {
if (( $# != 1 )); then
builtin cd "$@"
return
fi
if [[ -f "$1" ]]; then
builtin cd "$1:h"
else
builtin cd "$1"
fi
}
z () {
cd ~/"$1"
}
alias md='mkdir -p'
alias rd=rmdir
alias d='dirs -v'
po () {
popd "$@"
dirs -v
}
# }}}
# {{{ Renaming
autoload zmv
alias mmv='noglob zmv -W'
# }}}
# {{{ tree
alias tre='tree -C'
# }}}
# }}}
# {{{ Job/process control
alias j='jobs -l'
alias dn=disown
compdef _jobs_fg dn
# }}}
# {{{ History
alias h='history -f 1 | less +G'
alias hh='history'
# }}}
# {{{ Environment
alias ts=typeset
compdef _typeset ts
# }}}
# {{{ Terminal
alias cls='clear'
alias term='echo $TERM'
# {{{ Changing terminal window/icon titles
which cx >&/dev/null || cx () { }
if [[ "$TERM" == ([Ex]term*|rxvt*|screen*) ]] && [[ -z "$SKIP_CX" ]]; then
# Could also look at /proc/$PPID/cmdline ...
# Don't do this, as it resets window titles set by tmux etc.
# cx
:
fi
# }}}
# }}}
# {{{ Other users
compdef _users lh
alias f='finger -m'
compdef _finger f
# su changes window title, even if we're not a login shell
su () {
command su "$@"
cx
}
# }}}
# {{{ No spelling correction
alias man='nocorrect man'
alias mysql='nocorrect mysql'
alias mysqlshow='nocorrect mysqlshow'
alias mkdir='nocorrect mkdir'
alias mv='nocorrect mv'
alias rj='nocorrect rj'
alias yast='nocorrect yast'
alias yast2='nocorrect yast2'
# }}}
# {{{ X windows related
# {{{ export DISPLAY=:0.0
sd () {
source $ZDOTDIR/.Xdisplay.${HOST%%.*}
}
# }}}
# }}}
# {{{ Different CVS setups
# Sensible defaults
unset CVS_SERVER
export CVSROOT
export CVS_RSH=ssh
# see scvs function
# }}}
# {{{ MIME handling
autoload zsh-mime-setup
zsh-mime-setup
# }}}
# {{{ Other programs
# {{{ less
if ! which less >&/dev/null; then
alias less=more
fi
alias v=less
alias vs='less -S'
if which batpipe >&/dev/null; then
eval "$(batpipe)"
# LESSOPEN="|$ZDOTDIR/bin/lesspipe.sh %s"
else
if which bat >&/dev/null; then
alias v=bat
fi
fi
if which batman >&/dev/null; then
alias man=batman
fi
# }}}
# {{{ editors
# enable ^Z
alias pico='/usr/bin/pico -z'
if which vim >&/dev/null; then
alias vi=vim
fi
# }}}
# {{{ arch
if which larch >&/dev/null; then
alias a=larch
compdef _larch a
fi
# }}}
# {{{ bzip2
alias bz=bzip2
alias buz=bunzip2
# }}}
# }}}
# {{{ Global aliases
# WARNING: global aliases are evil. Use with caution.
# {{{ For screwed up keyboards missing pipe
alias -g PIPE='|'
# }}}
# {{{ Lists of pipelines
alias -g AD='&& div &&'
# }}}
# {{{ Checking exit code
alias -g XS='; echo $?'
# }}}
# {{{ Paging with lnav / less / head / tail / dts
alias -g LN='| lnav -q'
alias -g L='| less'
alias -g LS='| less -S'
alias -g ELN='|& lnav -q'
alias -g EL='|& less'
alias -g ELS='|& less -S'
alias -g TRIM='| trim-lines'
alias -g H='| head'
alias -g HL='| head -n $(( +LINES ? LINES - 4 : 20 ))'
alias -g EH='|& head'
alias -g EHL='|& head -n $(( +LINES ? LINES - 4 : 20 ))'
alias -g T='| tail'
alias -g TL='| tail -n $(( +LINES ? LINES - 4 : 20 ))'
alias -g ET='|& tail'
alias -g ETL='|& tail -n $(( +LINES ? LINES - 4 : 20 ))'
alias -g DTS='|& dts'
alias -g F='| fzf'
alias -g EF='|& fzf'
# }}}
# {{{ Sorting / counting
alias -g C='| wc -l'
alias -g S='| sort'
alias -g Su='| sort -u'
alias -g Sn='| sort -n'
alias -g Snr='| sort -nr'
alias -g SUc='| sort | uniq -c'
alias -g SUd='| sort | uniq -d'
alias -g Uc='| uniq -c'
alias -g Ud='| uniq -d'
# }}}
# {{{ Common filenames
alias -g DN=/dev/null
alias -g DZ=/dev/zero
if [[ -e /var/log/syslog ]]; then
alias -g VM=/var/log/syslog
else
alias -g VM=/var/log/messages
fi
# }}}
# {{{ grep, xargs
# see also grep-shortcuts script
for global_alias_switches in {,i}{,l,L}{,r}{,v}{,C}; do
case "$global_alias_switches" in
*C*)
rhs_switches="${global_alias_switches//C/}"
color=--color=always
;;
*)
rhs_switches="$global_alias_switches"
color=
;;
esac
[ -n "$rhs_switches" ] && rhs_switches="-$rhs_switches"