Update .zshrc

This commit is contained in:
Out Of Ideas 2024-04-02 16:24:25 -05:00
parent c605c2dfac
commit 2f3b1674da
1 changed files with 365 additions and 8 deletions

View File

@ -10,7 +10,7 @@ if [[ $- != *i* ]] ; then
return
fi
#exec fastfetch
if [ -e /home/vehementham/.nix-profile/etc/profile.d/nix.sh ]; then . /home/vehementham/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer
#source .profile
@ -36,12 +36,28 @@ alias doas="doas "
alias bat="bat --plain --paging never --theme='Catppuccin-macchiato'"
alias eza="eza --long --icons --git --no-permissions"
alias neofetch="clear && neofetch"
alias fastfetch="clear && fastfetch"
alias audio-dlp="yt-dlp -f \"bestaudio\" --extract-audio --audio-format vorbis"
alias hfnn="fc -ln 0"
alias cmd="command"
alias c="cd"
alias fetch="fastfetch"
alias copy="wl-copy"
alias c="cd"
alias e="eza"
alias b="bat"
# If eza is not installed check if exa is installed, and if that is not installed, alias to ls
if type eza &> /dev/null; then
alias e="eza"
elif tye exa &> /dev/null; then
alias e="exa"
else
alias e="ls"
fi
# If bat is not installed, alias to cat
if type bat &> /dev/null; then
alias b="bat"
else
alias b="cat"
fi
alias n="nvim"
alias d="pwd"
alias k="rm"
@ -49,10 +65,25 @@ alias y="cp"
alias no="nano"
alias v="vi"
alias vm="vim"
alias vs="vis"
alias t="ed"
alias r="ex"
alias f="find"
alias src="source"
alias gr="grep"
alias g="git"
alias ga="git add"
alias gaa="git add -A"
alias gc="git commit -m"
alias gp="git push"
alias gch="git checkout"
alias gcl="git clone"
alias gpl="git pull"
alias p="pkg"
alias ap="apk"
alias ap="doas apk add"
alias apd="doas apk del"
alias aps="apk search"
alias pa="pkg_add"
alias pi="pkg_info"
alias cm="chmod"
@ -71,6 +102,7 @@ alias u="dd"
alias wai="whoami"
alias h="echo"
alias a="awk"
alias se="sed"
alias llama2="~/LLaMa2/llama.cpp/main -m ~/LLaMa2/llama.cpp/models/llama-2-13b-chat.Q6_K.gguf --color -c 4096 --temp 0.7 --repeat_penalty 1.1 -n -1 -i -ins"
###########################
@ -83,6 +115,7 @@ export MANPAGER='nvim +Man!'
# Bat
BAT_PAGER=""
# Terminal Emulator
export TERM=foot
# Configuration Directory
@ -90,21 +123,55 @@ export XDG_CONFIG_DIR="$HOME/.config"
# Vis Path
VIS_PATH="$XDG_CONGIG_DIR/vis"
###########
# Plugins #
###########
# Directory Variables
PLUGIN_PATH="$HOME/.config/zsh/plugins"
SYNTAX_HIGHLIGHTING_PATH="$PLUGIN_PATH/F-Sy-H/F-Sy-H.plugin.zsh"
AUTOSUGGESTIONS_PATH="$PLUGIN_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh"
HISTORY_SUBSTRING_SEARCH_PATH="$PLUGIN_PATH/zsh-history-substring-search/zsh-history-substring-search.zsh"
YOU_SHOULD_USE_PATH="$PLUGIN_PATH/zsh-you-should-use/zsh-you-should-use.plugin.zsh"
# Install plugins if they are not already installed
if ! ls $SYNTAX_HIGHLIGHTING_PATH &> /dev/null; then
git clone https://github.com/z-shell/F-Sy-H $SYNTAX_HIGHLIGHTING_PATH
fi
if ! ls $AUTOSUGGESTIONS_PATH &> /dev/null; then
git clone https://github.com/zsh-users/zsh-autosuggestions $AUTOSUGGESTIONS_PATH
fi
if ! ls $HISTORY_SUBSTRING_SEARCH_PATH &> /dev/null; then
git clone https://github.com/zsh-users/zsh-history-substring-search $HISTORY_SUBSTRING_SEARCH_PATH
fi
if ! ls $YOU_SHOULD_USE_PATH &> /dev/null; then
git clone https://github.com/MichaelAquilina/zsh-you-should-use $YOU_SHOULD_USE_PATH
fi
# Syntax Highlighting
source "$HOME/.config/zsh/plugins/F-Sy-H/F-Sy-H.plugin.zsh"
source $SYNTAX_HIGHLIGHTING_PATH
# Auto Suggestions
source "$HOME/.config/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
source $AUTOSUGGESTIONS_PATH
# Hisory Substring Search
source "$HOME/.config/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh"
source $HISTORY_SUBSTRING_SEARCH_PATH
# You should use
source $YOU_SHOULD_USE_PATH
##################
# Autocompletion #
##################
autoload -Uz compinit && compinit
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
###########
# Options #
# History #
###########
HISTFILE=~/.histfile
HISTSIZE=1000
@ -138,6 +205,296 @@ bindkey '^[[1;5D' backward-word
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
if [ -e /home/vehementham/.nix-profile/etc/profile.d/nix.sh ]; then . /home/vehementham/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer
################
# Shift Select #
################
# for my own convenience I explicitly set the signals
# that my terminal sends to the shell as variables.
# you might have different signals. you can see what
# signal each of your keys sends by running `cat`
# and pressing keys (you'll be able to see most keys)
# also some of the signals sent might be set in your
# terminal emulator application/program
# configurations/preferences. finally some terminals
# have a feature that shows you what signals are sent
# per key press.
#
# for context, at the time of writing these variables are
# set for the kitty terminal program, i.e these signals
# are mostly ones sent by default by this terminal.
export KEY_ALT_F='^[f'
export KEY_ALT_B='^[b'
export KEY_ALT_D='^[d'
export KEY_CTRL_U='^U'
export KEY_CTRL_BACKSPACE='^H'
export KEY_CTRL_Z='^Z'
export KEY_SHIFT_CTRL_Z='^[Z'
export KEY_CTRL_R='^R'
export KEY_SHIFT_CTRL_C='^[C'
export KEY_SHIFT_CTRL_X='^[X'
export KEY_SHIFT_CTRL_V='^[V'
export KEY_CTRL_A='^A'
export KEY_CTRL_L='^L'
export KEY_LEFT='^[[D'
export KEY_RIGHT='^[[C'
export KEY_SHIFT_UP='\e[1;2A'
export KEY_SHIFT_DOWN='\e[1;2B'
export KEY_SHIFT_RIGHT='\e[1;2C'
export KEY_SHIFT_LEFT='^[[1;2D'
export KEY_ALT_LEFT='^[[1;3D'
export KEY_ALT_RIGHT='^[[1;3C'
export KEY_SHIFT_ALT_LEFT='\e[1;4D'
export KEY_SHIFT_ALT_RIGHT='\e[1;6C'
export KEY_CTRL_LEFT='^[[1;5D'
export KEY_CTRL_RIGHT='^[[1;5C'
export KEY_SHIFT_CTRL_LEFT='\E[1;6D'
export KEY_SHIFT_CTRL_RIGHT='\E[1;6C'
export KEY_CTRL_A='^A'
export KEY_CTRL_E='^E'
export KEY_SHIFT_CTRL_A='^[A'
export KEY_SHIFT_CTRL_E='^[E'
export KEY_CTRL_D='^[[3~'
export KEY_END='\EOF'
export KEY_END2='\E4~'
export KEY_HOME='\EOH'
export KEY_HOME2='\E1~'
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
# copy selected terminal text to clipboard
zle -N widget::copy-selection
function widget::copy-selection {
if ((REGION_ACTIVE)); then
zle copy-region-as-kill
printf "%s" $CUTBUFFER | pbcopy
fi
}
# cut selected terminal text to clipboard
zle -N widget::cut-selection
function widget::cut-selection() {
if ((REGION_ACTIVE)) then
zle kill-region
printf "%s" $CUTBUFFER | pbcopy
fi
}
# paste clipboard contents
zle -N widget::paste
function widget::paste() {
((REGION_ACTIVE)) && zle kill-region
RBUFFER="$(pbpaste)${RBUFFER}"
CURSOR=$(( CURSOR + $(echo -n "$(pbpaste)" | wc -m | bc) ))
}
# select entire prompt
zle -N widget::select-all
function widget::select-all() {
local buflen=$(echo -n "$BUFFER" | wc -m | bc)
CURSOR=$buflen # if this is messing up try: CURSOR=9999999
zle set-mark-command
while [[ $CURSOR > 0 ]]; do
zle beginning-of-line
done
}
# scrolls the screen up, in effect clearing it
zle -N widget::scroll-and-clear-screen
function widget::scroll-and-clear-screen() {
printf "\n%.0s" {1..$LINES}
zle clear-screen
}
function widget::util-select() {
((REGION_ACTIVE)) || zle set-mark-command
local widget_name=$1
shift
zle $widget_name -- $@
}
function widget::util-unselect() {
REGION_ACTIVE=0
local widget_name=$1
shift
zle $widget_name -- $@
}
function widget::util-delselect() {
if ((REGION_ACTIVE)) then
zle kill-region
else
local widget_name=$1
shift
zle $widget_name -- $@
fi
}
function widget::util-insertchar() {
((REGION_ACTIVE)) && zle kill-region
RBUFFER="${1}${RBUFFER}"
zle forward-char
}
# | key sequence | command
# --------------------- | ------------------------------- | -------------
bindkey $KEY_ALT_F forward-word
bindkey $KEY_ALT_B backward-word
bindkey $KEY_ALT_D kill-word
bindkey $KEY_CTRL_U backward-kill-line
bindkey $KEY_CTRL_BACKSPACE backward-kill-word
bindkey $KEY_CTRL_Z undo
bindkey $KEY_SHIFT_CTRL_Z redo
bindkey $KEY_CTRL_R history-incremental-search-backward
bindkey $KEY_SHIFT_CTRL_C widget::copy-selection
bindkey $KEY_SHIFT_CTRL_X widget::cut-selection
bindkey $KEY_SHIFT_CTRL_V widget::paste
bindkey $KEY_SHIFT_CTRL_A widget::select-all
bindkey $KEY_CTRL_L widget::scroll-and-clear-screen
for keyname kcap seq mode widget (
left kcub1 $KEY_LEFT unselect backward-char
right kcuf1 $KEY_RIGHT unselect forward-char
shift-up kri $KEY_SHIFT_UP select up-line-or-history
shift-down kind $KEY_SHIFT_DOWN select down-line-or-history
shift-right kRIT $KEY_SHIFT_RIGHT select forward-char
shift-left kLFT $KEY_SHIFT_LEFT select backward-char
alt-right x $KEY_ALT_RIGHT unselect forward-word
alt-left x $KEY_ALT_LEFT unselect backward-word
shift-alt-right x $KEY_SHIFT_ALT_RIGHT select forward-word
shift-alt-left x $KEY_SHIFT_ALT_LEFT select backward-word
ctrl-right x $KEY_CTRL_RIGHT unselect forward-word
ctrl-left x $KEY_CTRL_LEFT unselect backward-word
shift-cmd-right x $KEY_SHIFT_CTRL_RIGHT select end-of-line
shift-cmd-left x $KEY_SHIFT_CTRL_LEFT select beginning-of-line
ctrl-e x $KEY_CTRL_E unselect end-of-line
ctrl-a x $KEY_CTRL_A unselect beginning-of-line
shift-ctrl-e x $KEY_SHIFT_CTRL_E select end-of-line
shift-ctrl-a x $KEY_SHIFT_CTRL_A select beginning-of-line
shift-ctrl-right x $KEY_SHIFT_CTRL_RIGHT select forward-word
shift-ctrl-left x $KEY_SHIFT_CTRL_LEFT select backward-word
del x $KEY_CTRL_D delselect delete-char
a x 'a' insertchar 'a'
b x 'b' insertchar 'b'
c x 'c' insertchar 'c'
d x 'd' insertchar 'd'
e x 'e' insertchar 'e'
f x 'f' insertchar 'f'
g x 'g' insertchar 'g'
h x 'h' insertchar 'h'
i x 'i' insertchar 'i'
j x 'j' insertchar 'j'
k x 'k' insertchar 'k'
l x 'l' insertchar 'l'
m x 'm' insertchar 'm'
n x 'n' insertchar 'n'
o x 'o' insertchar 'o'
p x 'p' insertchar 'p'
q x 'q' insertchar 'q'
r x 'r' insertchar 'r'
s x 's' insertchar 's'
t x 't' insertchar 't'
u x 'u' insertchar 'u'
v x 'v' insertchar 'v'
w x 'w' insertchar 'w'
x x 'x' insertchar 'x'
y x 'y' insertchar 'y'
z x 'z' insertchar 'z'
A x 'A' insertchar 'A'
B x 'B' insertchar 'B'
C x 'C' insertchar 'C'
D x 'D' insertchar 'D'
E x 'E' insertchar 'E'
F x 'F' insertchar 'F'
G x 'G' insertchar 'G'
H x 'H' insertchar 'H'
I x 'I' insertchar 'I'
J x 'J' insertchar 'J'
K x 'K' insertchar 'K'
L x 'L' insertchar 'L'
M x 'M' insertchar 'M'
N x 'N' insertchar 'N'
O x 'O' insertchar 'O'
P x 'P' insertchar 'P'
Q x 'Q' insertchar 'Q'
R x 'R' insertchar 'R'
S x 'S' insertchar 'S'
T x 'T' insertchar 'T'
U x 'U' insertchar 'U'
V x 'V' insertchar 'V'
W x 'W' insertchar 'W'
X x 'X' insertchar 'X'
Y x 'Y' insertchar 'Y'
Z x 'Z' insertchar 'Z'
0 x '0' insertchar '0'
1 x '1' insertchar '1'
2 x '2' insertchar '2'
3 x '3' insertchar '3'
4 x '4' insertchar '4'
5 x '5' insertchar '5'
6 x '6' insertchar '6'
7 x '7' insertchar '7'
8 x '8' insertchar '8'
9 x '9' insertchar '9'
exclamation-mark x '!' insertchar '!'
hash-sign x '\#' insertchar '\#'
dollar-sign x '$' insertchar '$'
percent-sign x '%' insertchar '%'
ampersand-sign x '\&' insertchar '\&'
star x '\*' insertchar '\*'
plus x '+' insertchar '+'
comma x ',' insertchar ','
dot x '.' insertchar '.'
forwardslash x '\\' insertchar '\\'
backslash x '/' insertchar '/'
colon x ':' insertchar ':'
semi-colon x '\;' insertchar '\;'
left-angle-bracket x '\<' insertchar '\<'
right-angle-bracket x '\>' insertchar '\>'
equal-sign x '=' insertchar '='
question-mark x '\?' insertchar '\?'
left-square-bracket x '[' insertchar '['
right-square-bracket x ']' insertchar ']'
hat-sign x '^' insertchar '^'
underscore x '_' insertchar '_'
left-brace x '{' insertchar '{'
right-brace x '\}' insertchar '\}'
left-parenthesis x '\(' insertchar '\('
right-parenthesis x '\)' insertchar '\)'
pipe x '\|' insertchar '\|'
tilde x '\~' insertchar '\~'
at-sign x '@' insertchar '@'
dash x '\-' insertchar '\-'
double-quote x '\"' insertchar '\"'
single-quote x "\'" insertchar "\'"
backtick x '\`' insertchar '\`'
whitespace x '\ ' insertchar '\ '
) {
eval "function widget::key-$keyname() {
widget::util-$mode $widget \$@
}"
zle -N widget::key-$keyname
bindkey $seq widget::key-$keyname
}
# Fixes autosuggest completion being overriden by keybindings:
# to have [zsh] autosuggest [plugin feature] complete visible
# suggestions, you can assign an array of shell functions to
# the `ZSH_AUTOSUGGEST_ACCEPT_WIDGETS` variable. When these
# functions are triggered, they will also complete any visible
# suggestion. Example:
export ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(
widget::key-right
widget::key-shift-right
widget::key-cmd-right
widget::key-shift-cmd-right
)