blob: 815b5c84151e563945272725a770a1b552adc396 (
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
#!/bin/zsh
# Exports
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export XDG_DOWNLOAD_DIR="${HOME}/downloads"
export XDG_CONFIG_HOME="${HOME}/.config"
export XDG_CACHE_HOME="${HOME}/.cache"
export XDG_DATA_HOME="${HOME}/.local/share"
export XDG_DESKTOP_DIR="${HOME}/desktop"
export XDG_TEMPLATES_DIR="${HOME}/temp"
export XDG_PUBLICSHARE_DIR="${HOME}/public"
export XDG_DOCUMENTS_DIR="${HOME}/documents"
export XDG_MUSIC_DIR="${HOME}/music"
export XDG_PICTURES_DIR="${HOME}/pictures"
export XDG_VIDEOS_DIR="${HOME}/videos"
export PATH="$PATH:$HOME/.cargo/bin"
export PATH="$PATH:$HOME/go/bin"
export PATH="$PATH:$HOME/.local/bin"
export EDITOR="nvim"
export HISTFILE="${HOME}/.zsh_history"
export HISTCONTROL="ignoredups:ignorespace"
export HISTSIZE="100000"
export HISTFILESIZE="200000"
export SAVEHIST="${HISTSIZE}"
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Functions ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
function _have {
prog="${1}"
os="${2}"
if [ "${os}" != "" ] && [ "${os}" != "${OS}" ]
then
return 1
fi
type "${prog}" > /dev/null
return "$?"
}
# Set the runtime variable
if _have sway linux
then
alias sway-launch="dbus-launch --exit-with-session sway"
if test -z "${XDG_RUNTIME_DIR}"; then
export XDG_RUNTIME_DIR=/tmp/"${UID}"-runtime-dir
if ! test -d "${XDG_RUNTIME_DIR}"; then
mkdir "${XDG_RUNTIME_DIR}"
chmod 0700 "${XDG_RUNTIME_DIR}"
fi
fi
fi
# === Media ===
function video-to-gif() {
fps="$3"
if [[ "$3" == "" ]];
then
fps="10"
fi
ffmpeg \
-i "$1" \
-filter_complex \
$(printf "%s%s%s%s" \
"[0:v]setpts=0.5*PTS,fps=" \
$fps \
",scale=800:-1:flags=lanczos,split[s0][s1];" \
"[s0]palettegen[p];[s1][p]paletteuse") \
-filter:a 'atempo=1,atempo=1' \
-loop 0 \
"$2"
}
function cut() {
start_time="$2"
end_time="$3"
input_file="$1"
if [[ "$end_time" == "" ]]; then
ffmpeg -ss "$start_time" \
-i "$input_file" \
-c copy "$(date +"%Y%m%d_%H%M ")$input_file" \
|| printf "Usage: %s <input file> <start> <end>\n" "$0"
elif [[ "$end_time" != "" ]]; then
ffmpeg -ss "$start_time" -to "$end_time" \
-i "$input_file" \
-c copy "$(date +"%Y%m%d_%H%M ")$input_file" \
|| printf "Usage: %s <input file> <start> <end>\n" "$0"
fi
}
# make an executable file w/ one line
function tx(){
file="$1"
[[ "$file" == "" ]] && echo -e "Usage: $0 <file name>\n"
if [ -f "$file" ]; then
echo "$file already exists. Making it executable."
chmod +x "$file"
else
touch "$file" && chmod +x "$file"
fi
}
# Waydroid
function droid(){
case "$1" in
stop)
waydroid session stop
;;
restart)
if [ pgrep -a waydroid != "" ]; then
waydroid session stop
setsid -f waydroid session start
else
setsid -f waydroid session start
fi
;;
*)
printf "Usage: %s {start|stop}\n" "$0"
exit 1
esac
}
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ ZSH Plugins ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
ZSH_CUSTOM="$HOME/.config/zsh/plugins"
plugins=(
zsh-autosuggestions
zsh-syntax-highlighting
)
for plugin in $plugins; do
source "$ZSH_CUSTOM/$plugin/${plugin}.zsh"
done
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#999999"
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Completion system (modern menu) ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
autoload -Uz compinit && compinit
zstyle ':completion:*' menu select # arrow-key menu
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' # case insensitive
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # colored completion
zstyle ':completion:*' rehash true # auto-refresh completion if new programs installed
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Keybinds ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
bindkey '^[[Z' autosuggest-accept # Shift+Tab accepts suggestion
bindkey '^ ' autosuggest-accept # Ctrl+Space also accepts
bindkey '^[[A' history-beginning-search-backward # Up arrow: search history
bindkey '^[[B' history-beginning-search-forward # Down arrow: search history
# Common bindings for Alt + Arrow (Meta + Arrow)
bindkey '^[[1;3C' forward-word # Alt + Right
bindkey '^[[1;3D' backward-word # Alt + Left
# cd into a directory with fzf
source <(fzf --zsh)
bindkey -s '^f' '~/.local/bin/tmux-sessionizer\n'
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Alias ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
alias ls='ls --color=auto --group-directories-first'
alias ll='ls -lh --color=auto --group-directories-first'
alias la='ls -lah --color=auto --group-directories-first'
alias grep='grep --color=auto'
alias nv='nvim'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ Prompt with git status ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
# ========================= Single line prompt ======================
# Load version control info
autoload -Uz vcs_info
# Load colors
autoload -Uz colors && colors
# Run vcs_info before each prompt
precmd_functions+=(vcs_info)
# Enable prompt substitution
setopt prompt_subst
# Configure the format for git
zstyle ':vcs_info:git:*' formats ' (%b)'
zstyle ':vcs_info:git:*' enable git
# Set the PROMPT variable to include the vcs_info_msg_0_ variable
PROMPT='%F{#bb9af7}%~%f%F{#7dcfff}${vcs_info_msg_0_}%f %# '
# ===================== Double line prompt ======================
# autoload -Uz vcs_info # loads zsh's version-control info system
# setopt PROMPT_SUBST # allows variable/command expansion inside PROMPT
# palette — catppuccin mocha (prominent accents)
# MAUVE='%F{#cba6f7}' # signature Mocha accent — used for username
# BLUE='%F{#89b4fa}' # used for current path
# TEAL='%F{#94e2d5}' # used for git branch name
# YELLOW='%F{#f9e2af}' # used for unstaged-changes marker
# PEACH='%F{#fab387}' # used for staged-changes marker
# PINK='%F{#f5c2e7}' # used for git action (rebase/merge/etc)
# RED='%F{#f38ba8}' # used for prompt arrow on command failure
# GREEN='%F{#a6e3a1}' # used for prompt arrow on command success
# SUBTEXT='%F{#a6adc8}' # muted tone for structural characters/text
# RESET='%f' # resets foreground color back to default
# format for normal git state (branch + unstaged/staged indicators)
# zstyle ':vcs_info:git:*' formats "${SUBTEXT}on ${TEAL}%b${YELLOW}%u${PEACH}%c${RESET}"
# format used during an in-progress git action (e.g. rebase, merge)
# zstyle ':vcs_info:git:*' actionformats "${SUBTEXT}on ${TEAL}%b${SUBTEXT}|${PINK}%a${RESET}"
# zstyle ':vcs_info:*' check-for-changes true # enable staged/unstaged detection (can slow big repos)
# zstyle ':vcs_info:*' unstagedstr ' *' # symbol shown when there are unstaged changes
# zstyle ':vcs_info:*' stagedstr ' +' # symbol shown when there are staged changes
# precmd() { vcs_info } # runs vcs_info before each prompt draw, refreshing git status
# PROMPT='
# ${SUBTEXT}╭─${MAUVE}%n${SUBTEXT}@%m ${BLUE}%~${RESET} ${vcs_info_msg_0_}
# ${SUBTEXT}╰─%(?.${GREEN}.${RED})❯${RESET} '
# line 1: top border, username (%n), host (%m), current dir (%~), git info
# line 2: bottom border + arrow — %(?.X.Y) is a ternary: X if last command
# succeeded (exit code 0), Y otherwise
# Starship prompt
# for times when prompt gets boring
# eval "$(starship init zsh)"
|