blob: 02601e5652bfd272a487e3a374fe5b9698f3c036 (
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
|
#+title: ZSH Configuration
Set up completions.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*'
zstyle :compinstall filename '/home/jjanzen/.zshrc'
autoload -U compinit promptinit
compinit
promptinit
#+end_src
Enable Gentoo completions on my Gentoo system.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
if [ "$(uname)" = 'Linux' ] && grep -q 'ID=gentoo' /etc/os-release; then
prompt gentoo
fi
#+end_src
Set up the history with 1000 entries and ignored duplicate commands.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt hist_ignore_all_dups
#+end_src
Enable automatic =cd=.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
setopt autocd
#+end_src
Enable extended glob.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
setopt extendedglob
#+end_src
If a glob returns nothing, don't keep the =*=.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
setopt nullglob
#+end_src
Report the status of background jobs immediately.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
setopt notify
#+end_src
Disable the beep.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
unsetopt beep
#+end_src
Use =vi= keybindings.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
bindkey -v
#+end_src
Use =lesspipe= back end for =less= if it is installed.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
which lesspipe.sh &> /dev/null && export LESSOPEN="|lesspipe.sh %s"
#+end_src
Use =eza= as my =ls= command if it is installed.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
which eza &> /dev/null && alias ls=eza
#+end_src
Use Neovim as my =vi= and =vim= application if it is installed.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
which nvim &> /dev/null && alias vi=nvim && alias vim=nvim
#+end_src
If the Firefox binary is called =firefox-bin=, let =firefox= also run =firefox-bin=.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
which firefox-bin &> /dev/null && alias firefox=firefox-bin
#+end_src
Lazy =ls= shortcuts.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
alias ll='ls -alF'
alias la='ls -a'
alias l='ls -F'
alias sl='ls'
#+end_src
*** Prompt
Define function to write out icons for the git status.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
parse_git_dirty() {
git_status="$(git status 2> /dev/null)"
[[ "$git_status" =~ "use \"git push\" to publish your local commits" ]] && echo -n " %F{green}%f"
[[ "$git_status" =~ "Changes to be committed:" ]] && echo -n " %F{magenta}%f"
[[ "$git_status" =~ "Changes not staged for commit:" ]] && echo -n " %F{yellow}%f"
[[ "$git_status" =~ "Untracked files:" ]] && echo -n " %F{red}%f"
}
#+end_src
Enable git status in the prompt.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
setopt prompt_subst
autoload -Uz vcs_info
precmd () { vcs_info }
zstyle ':vcs_info:*' formats ' %F{blue}%b%f' # git(main)
#+end_src
Define the prompt as follows:
- Error code (if applicable)
- Path using =~= for the home directory and truncating if too long
- Git branch
- Git status
- =$= to mark the start of the prompt
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
PS1='%(?..%B%F{red}[%?%\]%f%b )%F{green}%20<...<%~%<<%f$vcs_info_msg_0_$(parse_git_dirty) $ '
#+end_src
Enable VPN shortcut.
#+begin_src sh :tangle ~/.zshrc :mkdirp yes
if [ "$(uname)" = 'Linux' ] && grep -q 'ID=gentoo' /etc/os-release; then
vpn () {
if test -f /tmp/vpn.lock; then
echo turning off vpn...
doas /usr/bin/wg-quick down gentoo-CA-340
rm /tmp/vpn.lock
else
echo turning on vpn...
doas /usr/bin/wg-quick up gentoo-CA-340
touch /tmp/vpn.lock
fi
}
fi
#+end_src
|