-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc.git.full
198 lines (157 loc) · 6.98 KB
/
zshrc.git.full
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
# Options section
setopt correct # Auto correct mistakes
setopt extendedglob # Extended globbing, allows using regular expressions with *
setopt nocaseglob # Case insensitive globbing
setopt rcexpandparam # Array expansion with parameters
setopt nocheckjobs # Don't warn about running processes when exiting
setopt numericglobsort # Sort filenames numerically when it makes sense
setopt nobeep # No beep
setopt appendhistory # Immediately append history instead of overwriting
setopt histignorealldups # If a new command is a duplicate, remove the older one
setopt autocd # If only directory path is entered, cd there
setopt promptsubst # Enable prompt substitution
# History Setup
HISTFILE=~/.zhistory
HISTSIZE=5000000
SAVEHIST=5000000
# Set up zstyle configurations
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' rehash true
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
# Granular control when navigating and editing text
WORDCHARS=${WORDCHARS//\/[&.;]}
# Prepare for Theming
autoload -U compinit colors zcalc # Load functions only when first called
compinit -d # Initialize completion system, create dump file
colors # Enable color support
setopt prompt_subst # Allow dynamic elements in the prompt
zmodload zsh/terminfo # Load module for terminal capability information
# Prompt
# --- vcs_info Setup ---
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' disable cvs svn bzr hg
# Define the branch formats:
zstyle ':vcs_info:*' formats '(%b)'
zstyle ':vcs_info:*' actionformats '(%b|%a)'
# --- Custom Git Status Function ---
function add_git_status_info() {
if [[ -n "$vcs_info_msg_0_" ]]; then
local git_status=""
local git_icon=" "
# Check for unstaged modifications:
if ! git diff --quiet --ignore-submodules 2>/dev/null; then
git_status="${git_status}(🔥)"
fi
# Check for staged changes:
if ! git diff --cached --quiet --ignore-submodules 2>/dev/null; then
git_status="${git_status}(📦)"
fi
# Check for untracked files:
if [[ -n "$(git ls-files --others --exclude-standard 2>/dev/null)" ]]; then
git_status="${git_status}(❓)"
fi
# If no changes are detected, show the up-to-date emoji:
if [[ -z "$git_status" ]]; then
git_status="(✅)"
fi
vcs_info_msg_0_="${git_icon}${vcs_info_msg_0_}${git_status}"
fi
}
# Ensure prompt substitution is enabled
setopt prompt_subst
# --- Use add-zsh-hook to add both functions to the precmd hook ---
autoload -Uz add-zsh-hook
add-zsh-hook precmd vcs_info
add-zsh-hook precmd add_git_status_info
# --- Prompt Setup ---
NEWLINE=$'\n'
PROMPT="%{$fg[cyan]%} 👤%n@%m %{$fg[magenta]%} %{$fg[yellow]%}📁 %~ %{$fg[magenta]%} %{$fg[green]%}\${vcs_info_msg_0_}%{$reset_color%}%f${NEWLINE}%F{yellow} %f "
RPROMPT='%F{cyan}%f%F{cyan}%T ▫️ $(acpi | grep -o "[0-9]*%" | grep -v "^0%$" | head -n 1)% %F{cyan}%f'
# Export Section
## General
export EDITOR=/usr/bin/nano
export VISUAL=/usr/bin/nano
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export SHELL=/usr/bin/zsh
export PATH="/home/$USER/bin:$HOME/.local/bin:$PATH"
# API Keys
export ANTHROPIC_KEY=""
export GOOGLE_API_KEY=""
export OPENAI_API_KEY=""
# Chrome
export CHROME_EXECUTABLE="/usr/bin/google-chrome-stable"
## Color man pages
export LESS_TERMCAP_mb=$'\E[01;32m'
export LESS_TERMCAP_md=$'\E[01;32m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;47;34m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;36m'
export LESS=-r
# Alias Section
alias cp="cp -i" # Confirm before overwriting something
alias df='df -h' # Human-readable sizes
alias free='free -m' # Show sizes in MB
alias ls='ls -Alh --color=auto --group-directories-first'
alias cmatrix='cmatrix -b -a -s'
alias reflect='sudo reflector --latest 20 --sort rate --download-timeout 3 --save /etc/pacman.d/mirrorlist'
alias pd='pandoc -V geometry:margin=2cm --pdf-engine=wkhtmltopdf'
# Plugins Sourcing and Setup
## First Plugin: zsh-syntax-highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
## Second Plugin: zsh-autosuggestions
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#50493e,bold"
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
## Third Plugin: zsh-history-substring-search
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
## Keybindings section
# Set default Emacs key bindings
bindkey -e
# Home key bindings
bindkey '^[[7~' beginning-of-line # Home key (variant 1)
bindkey '^[[H' beginning-of-line # Home key (variant 2)
if [[ "${terminfo[khome]}" != "" ]]; then
bindkey "${terminfo[khome]}" beginning-of-line # Home key (terminfo)
fi
# End key bindings
bindkey '^[[8~' end-of-line # End key (variant 1)
bindkey '^[[F' end-of-line # End key (variant 2)
if [[ "${terminfo[kend]}" != "" ]]; then
bindkey "${terminfo[kend]}" end-of-line # End key (terminfo)
fi
# Other special keys
bindkey '^[[2~' overwrite-mode # Insert key
bindkey '^[[3~' delete-char # Delete key
bindkey '^[[C' forward-char # Right arrow key
bindkey '^[[D' backward-char # Left arrow key
bindkey '^[[5~' history-beginning-search-backward # Page Up key
bindkey '^[[6~' history-beginning-search-forward # Page Down key
# Ctrl+Arrow keys for word navigation
bindkey '^[Oc' forward-word # Ctrl+Right Arrow (variant 1)
bindkey '^[Od' backward-word # Ctrl+Left Arrow (variant 1)
bindkey '^[[1;5D' backward-word # Ctrl+Left Arrow (variant 2)
bindkey '^[[1;5C' forward-word # Ctrl+Right Arrow (variant 2)
# History substring search
bindkey '^[[A' history-substring-search-up # Up arrow key for history substring search
bindkey '^[[B' history-substring-search-down # Down arrow key for history substring search
# Other useful keybindings
bindkey '^H' backward-kill-word # Ctrl+Backspace to delete previous word
bindkey '^[[Z' undo # Shift+Tab to undo last action
# Fabric Framework related
alias paste='wl-paste'
alias copy='wl-copy'
yt() {
local video_link="$1"
fabric -y "$video_link" --transcript
}