annotate zshrc @ 34:2e02d7481487

add zsh config for it1
author Dirk Olmes <dirk.olmes@iobjects.de>
date Sat, 05 Jan 2013 04:38:32 +0100
parents 8d30bd0d3a50
children 2f93381e4ed8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
1 #
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
2 # This is the main zshrc file.
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
3 #
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
4
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
5 if [ -d $HOME/.oh-my-zsh ]; then
6
ff5e785e7bf7 tabs -> spaces
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 3
diff changeset
6 ZSH=$HOME/.oh-my-zsh
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
7 . $HOME/.zsh-env/oh-my-zsh
3
d31291a406ed look for oh-my-zsh in a system wide folder
Dirk Olmes <dirk.olmes@exentra.de>
parents: 1
diff changeset
8 elif [ -d /var/lib/zsh/oh-my-zsh ]; then
6
ff5e785e7bf7 tabs -> spaces
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 3
diff changeset
9 ZSH=/var/lib/zsh/oh-my-zsh
ff5e785e7bf7 tabs -> spaces
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 3
diff changeset
10 . $HOME/.zsh-env/oh-my-zsh
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
11 fi
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
12
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
13 # get rid of some unwanted aliases from the oh-my-zsh env
19
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
14 if [ "`alias | grep 'l='`" != "" ]; then
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
15 unalias l
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
16 fi
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
17 if [ "`alias | grep 'lsa='`" != "" ]; then
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
18 unalias lsa
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
19 fi
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
20
29
8d30bd0d3a50 provide a shortcut alias for pushd
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 21
diff changeset
21 # custom functions/aliases that should work on all platforms
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
22 cd() { builtin cd "$@"; print -D $PWD; }
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
23 ff() { find $2 -print0 | xargs -0 grep $1 }
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
24 hgrep() { history | grep $* }
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
25 mcd() { mkdir $1; cd $1 }
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
26 psg() { ps auxww | grep -v grep | grep -i "$@" }
29
8d30bd0d3a50 provide a shortcut alias for pushd
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 21
diff changeset
27 alias pd=pushd
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
28
10
6c4ab833e66d emulate tcsh's subprocess behaviour: automatically nohup the jobs, do not warn when exiting the shell
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 9
diff changeset
29 # no history handling for now ... or find a better way to save history per shell not across all shells
6c4ab833e66d emulate tcsh's subprocess behaviour: automatically nohup the jobs, do not warn when exiting the shell
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 9
diff changeset
30 export HISTFILE=
6c4ab833e66d emulate tcsh's subprocess behaviour: automatically nohup the jobs, do not warn when exiting the shell
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 9
diff changeset
31
6c4ab833e66d emulate tcsh's subprocess behaviour: automatically nohup the jobs, do not warn when exiting the shell
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 9
diff changeset
32 # emulate tcsh's behaviour for forked processes: do not warn, do not kill when shell is closed
6c4ab833e66d emulate tcsh's subprocess behaviour: automatically nohup the jobs, do not warn when exiting the shell
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 9
diff changeset
33 setopt nohup
6c4ab833e66d emulate tcsh's subprocess behaviour: automatically nohup the jobs, do not warn when exiting the shell
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 9
diff changeset
34 setopt no_check_jobs
6c4ab833e66d emulate tcsh's subprocess behaviour: automatically nohup the jobs, do not warn when exiting the shell
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 9
diff changeset
35
13
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
36 # ignore duplicates in history
12
13e0030ddaad ignore duplicate history entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 10
diff changeset
37 setopt hist_ignore_all_dups
13e0030ddaad ignore duplicate history entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 10
diff changeset
38
13
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
39 # get rid of the silly "zsh: sure you want to delete all the files in ..." message
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
40 unsetopt normstarsilent
10
6c4ab833e66d emulate tcsh's subprocess behaviour: automatically nohup the jobs, do not warn when exiting the shell
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 9
diff changeset
41
21
ee88f708d3ce turn of adding stuff to the directory stack automatically
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
42 # turn of the "helpful" zsh feature of pushing each directory to the dir stack on cd
ee88f708d3ce turn of adding stuff to the directory stack automatically
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
43 unsetopt autopushd
ee88f708d3ce turn of adding stuff to the directory stack automatically
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
44
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
45 # utility function that is used by various other modules
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
46 removeFromPath() {
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
47 search_term="$1"
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
48 split_path=(${(s/:/)PATH})
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
49 clean_path=""
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
50 for element in ${split_path}
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
51 do
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
52 if [[ "${element}" =~ "${search_term}" ]]; then
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
53 continue
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
54 fi
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
55
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
56 if [ ${#clean_path} -eq 0 ]; then
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
57 clean_path="${element}"
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
58 else
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
59 clean_path="${clean_path}:${element}"
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
60 fi
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
61 done
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
62 echo "${clean_path}"
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
63 }
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
64
13
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
65 # $HOST can either be just the host name or the FQDN. Standardize on the raw host name
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
66 export HOST=`echo $HOST | awk -F '.' '{ print $1 }'`
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
67
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
68 # include a zshrc per OS type
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
69 local os_zshrc=$HOME/.zsh-env/zshrc-$OSTYPE
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
70 if [ -f ${os_zshrc} ]; then
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
71 . ${os_zshrc}
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
72 fi
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
73
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
74 # include a zshrc per host
1
e12c50e8ea8c use the builtin HOST variable
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
75 local host_zshrc=$HOME/.zsh-env/zshrc-${HOST}
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
76 if [ -r ${host_zshrc} ]; then
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
77 . ${host_zshrc}
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
78 fi