1
0
Fork 0
This commit is contained in:
Arthur K. 2025-11-11 00:41:42 +03:00
parent 7e5d880156
commit d93f63cf82
40 changed files with 448 additions and 649 deletions

View file

@ -1,8 +1,13 @@
set -a
PATH="$HOME/.local/share/go/bin:$PATH"
PATH="\
$HOME/.local/share/go/bin:\
$HOME/.local/share/dotnet:\
$PATH"
PATH="${$(find -L ~/.local/bin ! -name '.*' -type d -printf %p:)%%:}:$PATH"
TIMEFMT=$'\ncmd\t%J\nreal\t%*E\nuser\t%U\nsys\t%S\ncpu\t%P'
# lc vars
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
@ -35,14 +40,15 @@ XDG_PICTURES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/"
# default configs
ANDROID_HOME="${HOME}/.local/share/android"
ANDROID_HOME="${HOME}/.local/share/android-home"
ANDROID_USER_HOME="${HOME}/.local/share/android-home"
ANDROID_AVD_HOME="${ANDROID_HOME}/avd"
BAT_THEME="TwoDark"
EDITOR="/usr/bin/nvim"
GNUPGHOME='~/.local/share/gnupg'
GOPATH="${HOME}/.local/share/go"
GPG_TTY="$(tty)"
JAVA_HOME="/usr/lib/jvm/java-23-openjdk"
JAVA_HOME="/usr/lib/jvm/java-21-openjdk"
LESS="-x4 --wheel-lines 3 --mouse"
MANPAGER="sh -c 'col -bx | bat -l man -p --theme Monokai\ Extended'"
MANROFFOPT="-c"
@ -53,5 +59,7 @@ GRADLE_USER_HOME="${HOME}/.local/share/gradle"
DOCKER_CONFIG="${HOME}/.local/share/docker"
COMPOSE_BAKE=true
GIT_DISCOVERY_ACROSS_FILESYSTEM=1
DOTNET_CLI_TELEMETRY_OPTOUT=1 # clippy <3
DOTNET_ROOT="${HOME}/.local/share/dotnet"
set +a

View file

@ -23,7 +23,6 @@ autoload -U select-word-style
select-word-style b
# options
setopt extendedglob
setopt auto_pushd
# keybinds
@ -58,7 +57,10 @@ alias lsd='/usr/bin/ls'
alias l="ls -lh"
alias la="ls -lah"
alias ll="ls -lh"
alias ltr='ls -lt'
alias lt="ls -ltr"
alias lss='ls -lS'
alias lsr='ls -lSr'
# set bat as help pager
alias -g -- --help='--help 2>&1 | bat --language=help --style=plain --theme Monokai\ Extended'
@ -84,12 +86,12 @@ alias sudo='sudo ' # allow aliases with sudo
alias rz='exec zsh'
alias venv='source src_venv'
alias ex='source src_example'
alias ap='source src_add_path'
alias pa='source src_add_path'
alias info='pinfo'
alias bat='bat '
alias img='nsxiv'
alias xclip='xclip -selection clipboard'
alias xxclip='head -c-1 | xclip -selection clipboard'
alias xcp='perl -pe "chomp if eof" | xclip -selection clipboard'
alias rgf='rg --files | rg'
alias wt='watch --color -d -cn 0.1 '
alias .e='set -a && source .env && set +a'
@ -97,30 +99,37 @@ alias vimu='vim -u /dev/null'
alias reswap="sudo bash -c 'echo Working...; swapoff /swapfile && sudo swapon /swapfile'"
alias make="make -j$(nproc)"
alias py='python3'
alias q='qalc'
alias neofetch='fastfetch'
alias open='xdg-open'
alias m.='if mount | grep -q "$(pwd)"; then umount -l .; cd .; else mount .; cd .; fi'
alias rs='stow -R .'
alias sst='ssh -t'
alias rdj='rmdir ./*'
alias qr='qrencode -t ansiutf8'
# function aliases
bl() { brightnessctl set "$1"% > /dev/null; }
nosw() { alacritty --class 'noswallow' -e "$@"; }; compdef _command nosw
t() { taskell "${1:-${HOME}/.taskell.md}"; }
vims() { filepath="$(type "$1" | rev | cut -d ' ' -f 1 | rev)"; [ $? -eq 0 ] && vim "${filepath}"; }; compdef _command vims
tl() { tree -C "$@" | bat }; compdef _tree tl
diff() { /usr/bin/diff --color -u "$@" | delta; }; compdef _files di
diff() { /usr/bin/diff --color -u "$@" | delta; }; compdef _files di;
# compdef
compdef -a '_git; _git-commit' gdc # todo
compdef '_files -g "*.md"' md
compdef _ollama ollama
# ansible
alias ap='ansible-playbook'
alias ag='ansible-galaxy'
# git aliases
gl() { git log --decorate "$@" | bat }; compdef '_git; _git-log' gl
gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}"}; compdef '_git; _git-push' gus
gpo() { git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)" "$@"}
gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}" }; compdef '_git; _git-push' gus
gpo() { git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)" "$@" }
gru() { git remote get-url "${1-origin}" }; compdef '_gor' gru
alias ga="git add"
alias ga.="git add ." # always fatfinger this
alias gb="git branch"
alias gc="git commit"
alias gca="git commit --allow-empty-message --amend --no-edit"
@ -131,7 +140,8 @@ alias gcls="git clone --depth=1"
alias gcm="git commit --allow-empty-message -m ''"
alias gcd='git commit --no-gpg-sign'
alias gcmd="git commit --allow-empty-message -m '' --no-gpg-sign"
alias gcn="git clean"
alias gcn="git clean -nfd"
alias gcn!="git clean -fd"
alias gcp="git cherry-pick"
alias gd="git diff"
alias gds="gd --staged"
@ -148,10 +158,12 @@ alias grjs="git rebase --cancel"
alias grm="git remote"
alias grs="git restore --staged"
alias grt="git reset"
alias grt!="git reset --hard"
alias gsm='git submodule'
alias grc='git rm --cached'
alias gs="git status"
alias gsc="git switch -c"
alias gs.='git status .'
alias gsc="git switch -C"
alias gsh="git show"
alias gsj="git stash"
alias gsp="git stash pop"
@ -159,6 +171,10 @@ alias gt="git tag"
alias gus="git fetch --unshallow"
alias gdj='DELTA_FEATURES="+side-by-side" gd'
alias gdsj='DELTA_FEATURES="+side-by-side" gds'
alias gshj='DELTA_FEATURES="+side-by-side" gsh'
alias gcln='git clean -nxfd'
alias gcln!='git clean -xfd'
alias gct="gc -am 'Add files via upload :trollface:'"
# docker aliases
alias d='docker'
@ -166,17 +182,22 @@ alias dc='docker compose'
alias d!='/usr/bin/docker'
alias dc!='d! compose'
alias dj='dc up -d --force-recreate'
alias djl='dc up -d --force-recreate && dl'
alias dl='dc logs -f'
alias dk='dc down'
alias dv='d volume'
alias di='d image'
alias dj='dc up -d --force-recreate'
alias djb='dj --build'
alias djbl='djb && dl'
alias djl='dj && dl'
alias dk='dc down'
alias dl='dc logs -f'
alias dr='d run --rm -it'
alias drs='dc restart'
alias drsl='dc restart && dl'
alias dv='d volume'
# tmux stuff
tn() { tmux new-session -s "${1-"$(basename "$(pwd)")"}" }
alias ta="tmux a -t"
alias ta='tmux a -t'
# ta() { tmux a -t "$1" }; compdef '_tmux; _tmux-attach-session' ta
# disable xon control chars
stty -ixon

View file

@ -1,3 +1,5 @@
#!/usr/bin/zsh
mode::enable() {
local mode_path="${HOME}/.config/zsh/modes/$1.sh"
[ ! -f "$mode_path" ] && echo "Mode not found!" && return 1
@ -11,6 +13,18 @@ mode::enable() {
}
mode::get_functions() {
perl -ne '/^(?>function\s+)?([\x21-\x7e]+)\s*\(\)/ && print "$1\n"' < "$1"
}
mode::get_variables() {
perl -ne '/^(?>declare\s+(?>--?\w+\s*)+\s*)?\s*([\x21-\x3c\x3e-\x7e]+)=.*$/ && print "$1\n"' < "$1"
}
mode::get_aliases() {
perl -ne '/^(?:noglob\s+)?alias ([\x21-\x3c\x3e-\x7e]+)=/ && print "$1\n"' < "$1"
}
mode::disable() {
export PS1="${MODE__OLD_PS1}"
local mode_path="${HOME}/.config/zsh/modes/$MODE__ACTIVE_MODE.sh"
@ -18,45 +32,78 @@ mode::disable() {
unset -v "MODE__OLD_PS1"
unset -v "MODE__ACTIVE_MODE"
for mode_variable in $(perl -ne '/^(?>declare\s+(?>--?\w+\s*)+\s*)?\s*([\x21-\x3c\x3e-\x7e]+)=.*$/ && print "$1\n"' < "$mode_path"); do
for mode_variable in $(mode::get_variables "$mode_path"); do
unset "$mode_variable"
done
for mode_function in $(perl -ne '/^(?>function\s+)?([\x21-\x7e]+)\s*\(\)/ && print "$1\n"' < "$mode_path"); do
for mode_function in $(mode::get_functions "$mode_path"); do
unset -f "$mode_function"
done
for mode_alias in $(perl -ne '/^alias ([\x21-\x3c\x3e-\x7e]+)=/ && print "$1\n"'< "$mode_path"); do
for mode_alias in $(mode::get_aliases "$mode_path"); do
unalias "$mode_alias"
done
}
mode::help() {
echo "USAGE"
echo " mode [-h]"
echo "Usage:"
echo " mode <MODENAME>"
echo " mode"
echo
echo "OPTIONS"
echo " -h for help lol"
echo
echo "AVAILABLE MODES"
echo "Available modes:"
for mode in ~/.config/zsh/modes/*; do
printf " %s\n" "$(basename "${mode%.sh}")"
done
}
m() {
[ -n "$MODE__ACTIVE_MODE" ] && mode::disable && return
local cmd="${1:?}"
case "$cmd" in
m() {
[ -n "$MODE__ACTIVE_MODE" ] && {
mode::disable
[ -z "$1" ] && return
}
[ -z "$1" ] && {
echo 'Error: Missing mode name!'
mode::help
return 1
} >&2
case "$1" in
"-h"|"--help")
mode::help
;;
*)
mode::enable "$cmd" || mode::help >&2
mode::enable "$1" || mode::help >&2
;;
esac
}
mm() {
[ -z "$MODE__ACTIVE_MODE" ] && return 1
local mode_path="${HOME}/.config/zsh/modes/$MODE__ACTIVE_MODE.sh"
echo "Active mode: $MODE__ACTIVE_MODE"
echo
echo 'Aliases: '
for mode_alias in $(mode::get_aliases "$mode_path"); do
printf ' '
alias "$mode_alias"
done
echo
echo 'Functions:'
for mode_function in $(mode::get_functions "$mode_path"); do
echo " $mode_function"
done
echo
echo 'Variables:'
for mode_variable in $(mode::get_variables "$mode_path"); do
echo " $mode_variable"
done
}
alias 'm?'=mm

7
.config/zsh/modes/dt.sh Normal file
View file

@ -0,0 +1,7 @@
alias db='dotnet build'
alias df='dotnet format'
alias dt='dotnet test'
alias dr='dotnet restore'
noglob alias df?='dotnet format --verify-no-changes'
alias dff='df; df; df?'
alias da='dff && db && dt'