Browse Source

zshrc added

master
Dirk Alders 1 year ago
parent
commit
57d7713094
1 changed files with 272 additions and 0 deletions
  1. 272
    0
      zshrc

+ 272
- 0
zshrc View File

@@ -0,0 +1,272 @@
1
+# ~/.zshrc file for zsh interactive shells.
2
+# see /usr/share/doc/zsh/examples/zshrc for examples
3
+
4
+# You should install some packages:
5
+# sudo apt install zsh zsh-syntax-highlighting zsh-autosuggestions qterminal fonts-firacode
6
+#
7
+
8
+setopt autocd              # change directory just by typing its name
9
+#setopt correct            # auto correct mistakes
10
+setopt interactivecomments # allow comments in interactive mode
11
+setopt magicequalsubst     # enable filename expansion for arguments of the form ‘anything=expression’
12
+setopt nonomatch           # hide error message if there is no match for the pattern
13
+setopt notify              # report the status of background jobs immediately
14
+setopt numericglobsort     # sort filenames numerically when it makes sense
15
+setopt promptsubst         # enable command substitution in prompt
16
+
17
+WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word
18
+
19
+# hide EOL sign ('%')
20
+PROMPT_EOL_MARK=""
21
+
22
+# configure key keybindings
23
+bindkey -e                                        # emacs key bindings
24
+bindkey ' ' magic-space                           # do history expansion on space
25
+bindkey '^U' backward-kill-line                   # ctrl + U
26
+bindkey '^[[3;5~' kill-word                       # ctrl + Supr
27
+bindkey '^[[3~' delete-char                       # delete
28
+bindkey '^[[1;5C' forward-word                    # ctrl + ->
29
+bindkey '^[[1;5D' backward-word                   # ctrl + <-
30
+bindkey '^[[5~' beginning-of-buffer-or-history    # page up
31
+bindkey '^[[6~' end-of-buffer-or-history          # page down
32
+bindkey '^[[H' beginning-of-line                  # home
33
+bindkey '^[[F' end-of-line                        # end
34
+bindkey '^[[Z' undo                               # shift + tab undo last action
35
+
36
+# enable completion features
37
+autoload -Uz compinit
38
+compinit -d ~/.cache/zcompdump
39
+zstyle ':completion:*:*:*:*:*' menu select
40
+zstyle ':completion:*' auto-description 'specify: %d'
41
+zstyle ':completion:*' completer _expand _complete
42
+zstyle ':completion:*' format 'Completing %d'
43
+zstyle ':completion:*' group-name ''
44
+zstyle ':completion:*' list-colors ''
45
+zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
46
+#zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
47
+zstyle ':completion:*' rehash true
48
+zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
49
+zstyle ':completion:*' use-compctl false
50
+zstyle ':completion:*' verbose true
51
+zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
52
+
53
+# History configurations
54
+HISTFILE=~/.zsh_history
55
+HISTSIZE=1000
56
+SAVEHIST=2000
57
+setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
58
+setopt hist_ignore_dups       # ignore duplicated commands history list
59
+setopt hist_ignore_space      # ignore commands that start with space
60
+setopt hist_verify            # show command with history expansion to user before running it
61
+#setopt share_history         # share command history data
62
+
63
+# force zsh to show the complete history
64
+alias history="history 0"
65
+
66
+# configure `time` format
67
+TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S\ncpu\t%P'
68
+
69
+# make less more friendly for non-text input files, see lesspipe(1)
70
+#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
71
+
72
+# set variable identifying the chroot you work in (used in the prompt below)
73
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
74
+    debian_chroot=$(cat /etc/debian_chroot)
75
+fi
76
+
77
+# set a fancy prompt (non-color, unless we know we "want" color)
78
+case "$TERM" in
79
+    xterm-color|*-256color) color_prompt=yes;;
80
+esac
81
+
82
+# uncomment for a colored prompt, if the terminal has the capability; turned
83
+# off by default to not distract the user: the focus in a terminal window
84
+# should be on the output of commands, not on the prompt
85
+force_color_prompt=yes
86
+
87
+if [ -n "$force_color_prompt" ]; then
88
+    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
89
+        # We have color support; assume it's compliant with Ecma-48
90
+        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
91
+        # a case would tend to support setf rather than setaf.)
92
+        color_prompt=yes
93
+    else
94
+        color_prompt=
95
+    fi
96
+fi
97
+
98
+configure_prompt() {
99
+    prompt_symbol=㉿
100
+    # Skull emoji for root terminal
101
+    [ "$EUID" -eq 0 ] && prompt_symbol=💀
102
+    case "$PROMPT_ALTERNATIVE" in
103
+        twoline)
104
+            PROMPT=$'%F{%(#.blue.green)}╔══${debian_chroot:+($debian_chroot)─}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))─}(%B%F{%(#.red.blue)}%n'$prompt_symbol$'%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n`giti -n`%F{%(#.blue.green)}╚═%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '
105
+            # Right-side prompt with exit codes and background processes
106
+            RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)'
107
+            ;;
108
+        oneline)
109
+            PROMPT=$'${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%B%F{%(#.red.blue)}%n@%m%b%F{reset}:%B%F{%(#.blue.green)}%~%b%F{reset}%(#.#.$) '
110
+            RPROMPT=
111
+            ;;
112
+        backtrack)
113
+            PROMPT=$'${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%B%F{red}%n@%m%b%F{reset}:%B%F{blue}%~%b%F{reset}%(#.#.$) '
114
+            RPROMPT=
115
+            ;;
116
+    esac
117
+    unset prompt_symbol
118
+}
119
+
120
+# The following block is surrounded by two delimiters.
121
+# These delimiters must not be modified. Thanks.
122
+# START KALI CONFIG VARIABLES
123
+PROMPT_ALTERNATIVE=twoline
124
+NEWLINE_BEFORE_PROMPT=yes
125
+# STOP KALI CONFIG VARIABLES
126
+
127
+if [ "$color_prompt" = yes ]; then
128
+    # override default virtualenv indicator in prompt
129
+    VIRTUAL_ENV_DISABLE_PROMPT=1
130
+
131
+    configure_prompt
132
+
133
+    # enable syntax-highlighting
134
+    if [ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then
135
+        . /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
136
+        ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
137
+        ZSH_HIGHLIGHT_STYLES[default]=none
138
+        ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=white,underline
139
+        ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold
140
+        ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline
141
+        ZSH_HIGHLIGHT_STYLES[global-alias]=fg=green,bold
142
+        ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline
143
+        ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold
144
+        ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline
145
+        ZSH_HIGHLIGHT_STYLES[path]=bold
146
+        ZSH_HIGHLIGHT_STYLES[path_pathseparator]=
147
+        ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=
148
+        ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold
149
+        ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold
150
+        ZSH_HIGHLIGHT_STYLES[command-substitution]=none
151
+        ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta,bold
152
+        ZSH_HIGHLIGHT_STYLES[process-substitution]=none
153
+        ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta,bold
154
+        ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=green
155
+        ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=green
156
+        ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
157
+        ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold
158
+        ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow
159
+        ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow
160
+        ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow
161
+        ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta
162
+        ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta,bold
163
+        ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta,bold
164
+        ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta,bold
165
+        ZSH_HIGHLIGHT_STYLES[assign]=none
166
+        ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold
167
+        ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold
168
+        ZSH_HIGHLIGHT_STYLES[named-fd]=none
169
+        ZSH_HIGHLIGHT_STYLES[numeric-fd]=none
170
+        ZSH_HIGHLIGHT_STYLES[arg0]=fg=cyan
171
+        ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
172
+        ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold
173
+        ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold
174
+        ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold
175
+        ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold
176
+        ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold
177
+        ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout
178
+    fi
179
+else
180
+    PROMPT='${debian_chroot:+($debian_chroot)}%n@%m:%~%(#.#.$) '
181
+fi
182
+unset color_prompt force_color_prompt
183
+
184
+toggle_oneline_prompt(){
185
+    if [ "$PROMPT_ALTERNATIVE" = oneline ]; then
186
+        PROMPT_ALTERNATIVE=twoline
187
+    else
188
+        PROMPT_ALTERNATIVE=oneline
189
+    fi
190
+    configure_prompt
191
+    zle reset-prompt
192
+}
193
+zle -N toggle_oneline_prompt
194
+bindkey ^P toggle_oneline_prompt
195
+
196
+# If this is an xterm set the title to user@host:dir
197
+case "$TERM" in
198
+xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty)
199
+    TERM_TITLE=$'\e]0;${debian_chroot:+($debian_chroot)}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))}%n@%m: %~\a'
200
+    ;;
201
+*)
202
+    ;;
203
+esac
204
+
205
+precmd() {
206
+    # Print the previously configured title
207
+    print -Pnr -- "$TERM_TITLE"
208
+
209
+    # Print a new line before the prompt, but only if it is not the first line
210
+    if [ "$NEWLINE_BEFORE_PROMPT" = yes ]; then
211
+        if [ -z "$_NEW_LINE_BEFORE_PROMPT" ]; then
212
+            _NEW_LINE_BEFORE_PROMPT=1
213
+        else
214
+            print ""
215
+        fi
216
+    fi
217
+}
218
+
219
+# enable color support of ls, less and man, and also add handy aliases
220
+if [ -x /usr/bin/dircolors ]; then
221
+    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
222
+    export LS_COLORS="$LS_COLORS:ow=30;44:" # fix ls color for folders with 777 permissions
223
+
224
+    alias ls='ls --color=auto'
225
+    #alias dir='dir --color=auto'
226
+    #alias vdir='vdir --color=auto'
227
+
228
+    alias grep='grep --color=auto'
229
+    alias fgrep='fgrep --color=auto'
230
+    alias egrep='egrep --color=auto'
231
+    alias diff='diff --color=auto'
232
+    alias ip='ip --color=auto'
233
+
234
+    export LESS_TERMCAP_mb=$'\E[1;31m'     # begin blink
235
+    export LESS_TERMCAP_md=$'\E[1;36m'     # begin bold
236
+    export LESS_TERMCAP_me=$'\E[0m'        # reset bold/blink
237
+    export LESS_TERMCAP_so=$'\E[01;33m'    # begin reverse video
238
+    export LESS_TERMCAP_se=$'\E[0m'        # reset reverse video
239
+    export LESS_TERMCAP_us=$'\E[1;32m'     # begin underline
240
+    export LESS_TERMCAP_ue=$'\E[0m'        # reset underline
241
+
242
+    # Take advantage of $LS_COLORS for completion as well
243
+    zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
244
+    zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
245
+fi
246
+
247
+# some more ls aliases
248
+alias ll='ls -l'
249
+alias la='ls -A'
250
+alias l='ls -CF'
251
+
252
+# enable auto-suggestions based on the history
253
+if [ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
254
+    . /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
255
+    # change suggestion color
256
+    ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999'
257
+fi
258
+
259
+if [ ! `which powerline-daemon` == "" ]; then
260
+    powerline-daemon -q
261
+    . /usr/share/powerline/bindings/zsh/powerline.zsh
262
+fi
263
+
264
+if [ ! `which neofetch` == "" ]; then
265
+    neofetch
266
+fi
267
+
268
+# enable command-not-found if installed
269
+if [ -f /etc/zsh_command_not_found ]; then
270
+    . /etc/zsh_command_not_found
271
+fi
272
+compinit

Loading…
Cancel
Save