annotate zshrc @ 188:757255b99cff default tip

Der Pfad von nano hat sich geƤndert
author Dirk Olmes <dirk.olmes@codedo.de>
date Tue, 14 Mar 2023 07:19:52 +0100
parents 7d3c872681cb
children
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
43
9fa883dc39e0 remove the ll alias right here, where the other aliases are removed, too
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 36
diff changeset
14 if [ "`alias | grep 'll='`" != "" ]; then
9fa883dc39e0 remove the ll alias right here, where the other aliases are removed, too
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 36
diff changeset
15 unalias ll
9fa883dc39e0 remove the ll alias right here, where the other aliases are removed, too
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 36
diff changeset
16 fi
19
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
17 if [ "`alias | grep 'l='`" != "" ]; then
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
18 unalias l
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
19 fi
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
20 if [ "`alias | grep 'lsa='`" != "" ]; then
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
21 unalias lsa
f5c6324fc952 remove aliases only if they exist
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 13
diff changeset
22 fi
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
23
47
9cc72008cf08 enable zsh's fancy autocomplete
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
24 # enable zsh's fancy autocomplete
99
a081e7a3977d Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 77
diff changeset
25 fpath=(~/.zsh-env/completion $fpath)
47
9cc72008cf08 enable zsh's fancy autocomplete
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
26 autoload -U compinit
127
4c87719f258c Avoid complaining about compinit when running as sudo
Dirk Olmes <dirk.olmes@codedo.de>
parents: 104
diff changeset
27
4c87719f258c Avoid complaining about compinit when running as sudo
Dirk Olmes <dirk.olmes@codedo.de>
parents: 104
diff changeset
28 # -u avoids compinit complaining when running as root (see man zshcompsys)
4c87719f258c Avoid complaining about compinit when running as sudo
Dirk Olmes <dirk.olmes@codedo.de>
parents: 104
diff changeset
29 compinit -u
47
9cc72008cf08 enable zsh's fancy autocomplete
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 43
diff changeset
30
29
8d30bd0d3a50 provide a shortcut alias for pushd
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 21
diff changeset
31 # custom functions/aliases that should work on all platforms
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
32 cd() { builtin cd "$@"; print -D $PWD; }
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
33 ff() { find $2 -print0 | xargs -0 grep $1 }
77
5cc3c67c9d3f add a helper function for listing non-comment lines in a file, increase history size
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 64
diff changeset
34 gve() { grep -ve '^#' $1 | uniq | less }
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
35 hgrep() { history | grep $* }
187
7d3c872681cb more braucht jetzt eine Option, damit am Ende "rausgefallen" wird
Dirk Olmes <dirk.olmes@codedo.de>
parents: 168
diff changeset
36 ll() { /usr/bin/env -u LC_ALL LANG=C ls -laFh "$@" | more -e }
168
75e3f2d8368c move the ll and lr functions into the general zshrc
Dirk Olmes <dirk.olmes@codedo.de>
parents: 164
diff changeset
37 lr() { /usr/bin/env -u LC_ALL LANG=C ls -rtlh "$@" }
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
38 mcd() { mkdir $1; cd $1 }
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
39 psg() { ps auxww | grep -v grep | grep -i "$@" }
168
75e3f2d8368c move the ll and lr functions into the general zshrc
Dirk Olmes <dirk.olmes@codedo.de>
parents: 164
diff changeset
40
75e3f2d8368c move the ll and lr functions into the general zshrc
Dirk Olmes <dirk.olmes@codedo.de>
parents: 164
diff changeset
41 alias gk="$HOME/.zsh-env/gk.sh"
75e3f2d8368c move the ll and lr functions into the general zshrc
Dirk Olmes <dirk.olmes@codedo.de>
parents: 164
diff changeset
42 alias history="history 1"
75e3f2d8368c move the ll and lr functions into the general zshrc
Dirk Olmes <dirk.olmes@codedo.de>
parents: 164
diff changeset
43 alias ny="nano -Y none"
29
8d30bd0d3a50 provide a shortcut alias for pushd
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 21
diff changeset
44 alias pd=pushd
162
0bd8976bd5fb add default aliases for gk and removeKernel
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 151
diff changeset
45 alias removeKernel="$HOME/.zsh-env/removeKernel"
104
b3ffe2fba3ac Add aliases for screen
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 99
diff changeset
46 alias sl='screen -ls'
b3ffe2fba3ac Add aliases for screen
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 99
diff changeset
47 alias sn='screen -S'
b3ffe2fba3ac Add aliases for screen
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 99
diff changeset
48 alias sr='screen -r'
147
163ef90dd755 add an alias for sudo typos
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 127
diff changeset
49 alias suod=sudo
58
93e011f2a836 add aliases for tmux
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 51
diff changeset
50 alias ta="tmux attach -t"
63
a543849b6888 add alias for listing tmux sessions
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 59
diff changeset
51 alias tl="tmux list-sessions"
59
582fde73557e update alias name
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 58
diff changeset
52 alias tn="tmux new -s"
151
55466fa02e0a move the upload alias to a more generic place
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 147
diff changeset
53 alias upload="rsync --partial --progress --rsh=ssh"
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
54
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
55 # 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
56 export HISTFILE=
77
5cc3c67c9d3f add a helper function for listing non-comment lines in a file, increase history size
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 64
diff changeset
57 export HISTSIZE=500
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
58
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
59 # 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
60 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
61 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
62
13
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
63 # ignore duplicates in history
12
13e0030ddaad ignore duplicate history entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 10
diff changeset
64 setopt hist_ignore_all_dups
13e0030ddaad ignore duplicate history entries
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 10
diff changeset
65
13
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
66 # 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
67 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
68
64
efe5f376e911 fix a typo in comments
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 63
diff changeset
69 # turn off the "helpful" zsh feature of pushing each directory to the dir stack on cd
21
ee88f708d3ce turn of adding stuff to the directory stack automatically
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
70 unsetopt autopushd
ee88f708d3ce turn of adding stuff to the directory stack automatically
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 19
diff changeset
71
36
2f93381e4ed8 turn of autocorrection
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 29
diff changeset
72 # turn off "helpful" auto correction
2f93381e4ed8 turn of autocorrection
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 29
diff changeset
73 unsetopt correct_all
2f93381e4ed8 turn of autocorrection
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 29
diff changeset
74
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
75 # utility function that is used by various other modules
43
9fa883dc39e0 remove the ll alias right here, where the other aliases are removed, too
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 36
diff changeset
76 removeFromPath()
9fa883dc39e0 remove the ll alias right here, where the other aliases are removed, too
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 36
diff changeset
77 {
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
78 search_term="$1"
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
79 split_path=(${(s/:/)PATH})
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
80 clean_path=""
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
81 for element in ${split_path}
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
82 do
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
83 if [[ "${element}" =~ "${search_term}" ]]; then
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
84 continue
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
85 fi
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
86
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
87 if [ ${#clean_path} -eq 0 ]; then
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
88 clean_path="${element}"
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
89 else
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
90 clean_path="${clean_path}:${element}"
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
91 fi
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
92 done
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
93 echo "${clean_path}"
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
94 }
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
95
13
f6fdf0fe99c3 do not warn when doing rm *
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 12
diff changeset
96 # $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
97 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
98
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
99 # include a zshrc per OS type
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
100 local os_zshrc=$HOME/.zsh-env/zshrc-$OSTYPE
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
101 if [ -f ${os_zshrc} ]; then
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
102 . ${os_zshrc}
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
103 fi
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
104
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
105 # include a zshrc per host
1
e12c50e8ea8c use the builtin HOST variable
Dirk Olmes <dirk@xanthippe.ping.de>
parents: 0
diff changeset
106 local host_zshrc=$HOME/.zsh-env/zshrc-${HOST}
0
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
107 if [ -r ${host_zshrc} ]; then
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
108 . ${host_zshrc}
8b245298349a zsh environment - initial import
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff changeset
109 fi