blob: 138c7b0729333e3c2a5b120f0371f03cef96c7db (
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
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
|
bindkey -e
# history
HISTFILE="$XDG_CACHE_HOME"/zsh/history
HISTCONTROL=ignoreboth
HISTSIZE=5000
SAVEHIST=10000
setopt inc_append_history
setopt autocd
setopt globdots extended_glob
setopt interactive_comments
unsetopt beep
stty stop undef
source "$XDG_CONFIG_HOME"/shellshort/shortcutrc
source "$XDG_CONFIG_HOME"/shellshort/shortcutenvrc
source "$XDG_CONFIG_HOME"/shellshort/zshnameddirs
zstyle ':completion:*' menu select=1
zstyle ':completion::complete:*' gain-privileges 1
zstyle ':completion:*' special-dirs \
'[[ $PREFIX = (../)#(|.|..) ]] && reply=(..)'
zstyle ':completion:*:default' list-colors ''
zstyle ':completion:*:matches' group 'yes'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-dirs-first true
zstyle :compinstall filename '$HOME/.zshrc'
autoload -Uz colors && colors
autoload -Uz compinit
zmodload zsh/complist
compinit
_comp_options+=(globdots)
typeset -g -A key
key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
key[Insert]="${terminfo[kich1]}"
key[Backspace]="${terminfo[kbs]}"
key[Delete]="${terminfo[kdch1]}"
key[PageUp]="${terminfo[kpp]}"
key[PageDown]="${terminfo[knp]}"
key[Shift-Tab]="${terminfo[kcbt]}"
key[Control-Left]="${terminfo[kLFT5]}"
key[Control-Right]="${terminfo[kRIT5]}"
# setup key accordingly
[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode
[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char
[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char
[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history
[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete
[[ -n "${key[Control-Left]}" ]] && bindkey -- "${key[Control-Left]}" backward-word
[[ -n "${key[Control-Right]}" ]] && bindkey -- "${key[Control-Right]}" forward-word
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init () {
echoti smkx
}
function zle-line-finish () {
echoti rmkx
}
zle -N zle-line-init
zle -N zle-line-finish
fi
# source /usr/share/gitstatus/gitstatus.prompt.zsh
PROMPT='%F{green}%n@%m%f ' # green user@host
# PROMPT+='%F{blue}%$((-GITSTATUS_PROMPT_LEN-1))<…<%~%<<%f' # blue current working directory
PROMPT+='%F{blue}%~%<<%f' # blue current working directory
# PROMPT+='${GITSTATUS_PROMPT:+ $GITSTATUS_PROMPT}' # git status
# PROMPT+=$'\n' # new line
PROMPT+=' %F{%(?.#888888.red)}%(!.#.$)%f ' # %/# (normal/root); green/red (ok/error)
function ls()
{
command ls --color=auto --indicator-style=classify --human-readable --literal --group-directories-first -v "$@" # -v is for natural sort of numbers within text
}
# coreutils
alias diff='diff --color=auto'
alias grep='grep --color=auto'
alias cp='cp -riv'
alias ll='ls --all -l --human-readable' # -l = long listing format
alias l='ls -l'
alias mkdir='mkdir -pv'
alias mv='mv -iv'
alias rm='rm -iv'
alias ..='echo "cd .."; cd ..'
alias ...='echo "cd ../.."; cd ../..'
# program aliases
alias m='aerc'
alias p='sudo pacman'
alias SS='sudo systemctl'
alias Su='systemctl --user'
alias v='nvim'
alias vn='NVIM_APPNAME=nvim-min nvim'
alias vv='uv run nvim'
alias neofetch='fastfetch -c examples/13'
alias cvim='nvim -c "cd ~/.config/nvim" -c "Oil"'
alias hm='home-manager --flake ~/nix'
# source: https://wiki.archlinux.org/title/GnuPG#Configure_pinentry_to_use_the_correct_TTY
GPG_TTY="$(tty)"
export GPG_TTY
gpg-connect-agent updatestartuptty /bye >/dev/null
export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
source <(fzf --zsh)
function lfcd()
{
export LF_CD_FILE=/tmp/.lfcd-$$
command lf "$@"
if [ -s "$LF_CD_FILE" ]; then
local DIR
DIR="$(realpath "$(cat "$LF_CD_FILE")")"
if [ "$DIR" != "$PWD" ]; then
echo "cd to $DIR"
cd "$DIR" || exit
fi
command rm "$LF_CD_FILE"
fi
unset LF_CD_FILE
}
function se()
{
choice="$(fd . ~/.local/bin -d1 -tx -tl --format '{/}' | fzf)"
[ -f "$HOME/.local/bin/$choice" ] && $EDITOR "$HOME/.local/bin/$choice"
}
function nb()
{
local curdate="$(date +'%Y-%m-%d %a %H:%M')"
local tmpfile=$(mktemp --tmpdir --suffix=.notes note.XXXXXXXXXXX)
printf "[%s] " "$curdate" >> "$tmpfile"
local mtime_before=$(stat -c %Y "$tmpfile")
nvim -c 'norm gg$' -c 'startinsert!' "$tmpfile"
local mtime_after=$(stat -c %Y "$tmpfile")
if [ "$mtime_after" -ne "$mtime_before" ]; then
local note="$(cat "$tmpfile")"
echo "$note" >> ~/refile.notes
fi
}
bindkey -s '^o' '^ulfcd\n'
bindkey -s '^[n' '^unb\n'
autoload edit-command-line
zle -N edit-command-line
bindkey '^x^e' edit-command-line
typeset -A ZSH_HIGHLIGHT_STYLES
ZSH_HIGHLIGHT_STYLES[suffix-alias]='fg=green'
ZSH_HIGHLIGHT_STYLES[precommand]='fg=green'
ZSH_HIGHLIGHT_STYLES[autodirectory]='fg=green'
ZSH_HIGHLIGHT_STYLES[path]='none'
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(brackets)
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|