This commit is contained in:
parent
c449dfcb5f
commit
559939e2f4
49 changed files with 729 additions and 252 deletions
|
|
@ -1,15 +1,2 @@
|
|||
[ -f "$HOME/.config/.fix-tty" ] || return
|
||||
|
||||
process_id="$$"
|
||||
(
|
||||
if [ "$(inxi -aG | grep -c 'Monitor')" = "1" ]; then
|
||||
setfont ter-v32n
|
||||
stty -F /proc/$process_id/fd/0 rows 65 cols 195
|
||||
else
|
||||
setfont ter-v16n
|
||||
stty -F /proc/$process_id/fd/0 rows 90 cols 320
|
||||
fi >/dev/null 2>&1 &
|
||||
)
|
||||
unset process_id
|
||||
|
||||
# vim: ft=sh
|
||||
pkill -0 gpg-agent || gpg-agent --daemon
|
||||
eval "$(ssh-agent)"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
set -a
|
||||
|
||||
PATH="\
|
||||
$HOME/.local/share/go/bin:\
|
||||
$HOME/.local/share/dotnet:\
|
||||
$PATH"
|
||||
PATH="${$(find -L ~/.local/bin ! -name '.*' -type d -printf %p:)%%:}:$PATH"
|
||||
|
||||
# `time` format
|
||||
TIMEFMT=$'\ncmd\t%J\nreal\t%*E\nuser\t%U\nsys\t%S\ncpu\t%P'
|
||||
|
||||
# lc vars
|
||||
|
|
@ -39,8 +34,9 @@ XDG_MUSIC_DIR="$HOME/"
|
|||
XDG_PICTURES_DIR="$HOME/"
|
||||
XDG_VIDEOS_DIR="$HOME/"
|
||||
|
||||
# default configs
|
||||
ANDROID_HOME="${HOME}/.local/share/android-home"
|
||||
# other
|
||||
ANDROID_HOME='/opt/android-sdk'
|
||||
ANDROID_SDK_ROOT='/opt/android-sdk'
|
||||
ANDROID_USER_HOME="${HOME}/.local/share/android-home"
|
||||
ANDROID_AVD_HOME="${ANDROID_HOME}/avd"
|
||||
BAT_THEME="TwoDark"
|
||||
|
|
@ -61,5 +57,13 @@ COMPOSE_BAKE=true
|
|||
GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT=1 # clippy <3
|
||||
DOTNET_ROOT="${HOME}/.local/share/dotnet"
|
||||
DELTA_FEATURES="-side-by-side"
|
||||
|
||||
PATH="\
|
||||
$HOME/.local/share/go/bin:\
|
||||
$HOME/.local/share/dotnet:\
|
||||
$ANDROID_HOME/cmdline-tools/latest/bin:
|
||||
$PATH"
|
||||
PATH="${$(find -L ~/.local/bin ! -name '.*' -type d -printf %p:)%%:}:$PATH"
|
||||
|
||||
set +a
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
. ~/.config/zsh/modes.sh
|
||||
|
||||
fpath=($HOME/.local/share/completions $fpath)
|
||||
|
||||
# ls colors
|
||||
eval "$(zoxide init zsh --cmd j)"
|
||||
eval "$(dircolors -b)"
|
||||
|
||||
# history
|
||||
|
|
@ -10,7 +7,6 @@ HISTSIZE=10000000
|
|||
SAVEHIST=10000000
|
||||
HISTFILE="${HOME}/.cache/zsh_history"
|
||||
alias history='history 1000000000000000'
|
||||
alias hist='history'
|
||||
|
||||
setopt hist_expire_dups_first
|
||||
setopt hist_ignore_dups
|
||||
|
|
@ -90,10 +86,9 @@ alias venv='source src_venv'
|
|||
alias ex='source src_example'
|
||||
alias pa='source src_add_path'
|
||||
alias info='pinfo'
|
||||
alias bat='bat '
|
||||
alias bat='bat'
|
||||
alias img='nsxiv'
|
||||
alias xclip='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'
|
||||
|
|
@ -107,78 +102,98 @@ 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 rdj='rmdir --ignore-fail-on-non-empty ./* 2>/dev/null'
|
||||
alias rdr='rmdir --ignore-fail-on-non-empty ./**/* 2>/dev/null'
|
||||
alias qr='qrencode -t ansiutf8'
|
||||
alias rgi='rg --no-ignore --hidden'
|
||||
alias rgi='rg -i'
|
||||
alias rgn='rg --no-ignore --hidden'
|
||||
alias rgni='rg --no-ignore --hidden -i'
|
||||
alias cal='cal -3'
|
||||
alias s='s '
|
||||
alias t='vi ~/todo.md'
|
||||
alias c.='cloc --vcs=git .'
|
||||
alias yt='noglob yt-dlp'
|
||||
alias b64='base64'
|
||||
|
||||
# function aliases
|
||||
mkexe() { touch "${1?}"; chmod +x "$1"; }; compdef _files mkexe;
|
||||
bl() { brightnessctl set "$1"% > /dev/null; }
|
||||
nosw() { alacritty --class 'noswallow' -e "$@"; }; compdef _command nosw
|
||||
vims() { filepath="$(type "$1" | rev | cut -d ' ' -f 1 | rev)"; [ $? -eq 0 ] && vim "${filepath}"; }; compdef _command vims
|
||||
tl() { tree -C "$@" | bat }; compdef _tree tl
|
||||
tl() { tree -C "$@" | bat; }; compdef _tree tl
|
||||
diff() { /usr/bin/diff --color -u "$@" | delta; }; compdef _files di;
|
||||
xcp() { perl -pe "chomp if eof" | xclip -selection clipboard; }
|
||||
|
||||
# compdef
|
||||
compdef -a '_git; _git-commit' gdc # todo
|
||||
compdef '_files -g "*.md"' md
|
||||
compdef _command s
|
||||
|
||||
# ansible
|
||||
alias ap='ansible-playbook'
|
||||
alias ag='ansible-galaxy'
|
||||
|
||||
# git aliases
|
||||
compdef -a '_git; _git-commit' gdc # todo
|
||||
compdef -a '_git; _git-ls-files' gls # todo
|
||||
# compdef -a '_git; _git-reset' grt # todo
|
||||
alias grt='git reset'
|
||||
|
||||
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)" "$@" }
|
||||
gru() { git remote get-url "${1-origin}" }; compdef '_gor' gru
|
||||
gtr() { gls $1 | tree --fromfile . }
|
||||
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"
|
||||
alias gca="git commit --allow-empty-message --amend --no-edit --date now"
|
||||
alias gcad='gca --no-gpg-sign'
|
||||
alias gcan="git commit --allow-empty-message --amend --no-edit --no-date"
|
||||
alias gcd='git commit --no-gpg-sign'
|
||||
alias gck="git checkout"
|
||||
alias gcl="git clone"
|
||||
alias gcln!='git clean -xfd'
|
||||
alias gcln='git clean -nxfd'
|
||||
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 -nfd"
|
||||
alias gcn!="git clean -fd"
|
||||
alias gcn="git clean -nfd"
|
||||
alias gcp="git cherry-pick"
|
||||
alias gct="gc -am 'Add files via upload :trollface:'"
|
||||
alias gd="git diff"
|
||||
alias gdj='DELTA_FEATURES="+side-by-side" gd'
|
||||
alias gds="gd --staged"
|
||||
alias 'gd?'="gd --stat"
|
||||
alias 'gds?'="gds --stat"
|
||||
alias gdsj='DELTA_FEATURES="+side-by-side" gds'
|
||||
alias gdv='git difftool --tool=vimdiff'
|
||||
alias gf="git fetch"
|
||||
alias gi="git init"
|
||||
alias gla="gl --all"
|
||||
alias glp='gl --pretty=fuller'
|
||||
alias gm="git merge"
|
||||
alias gp="git push"
|
||||
alias gpu="git pull"
|
||||
alias gr="git restore"
|
||||
alias grc='git rm --cached'
|
||||
alias grj="git rebase"
|
||||
alias grjc="git rebase --continue"
|
||||
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 grt!="grt --hard"
|
||||
alias gs="git status"
|
||||
alias gs.='git status .'
|
||||
alias gsc="git switch -C"
|
||||
alias gsh="git show"
|
||||
alias 'gsh?'="git show --stat"
|
||||
alias gshj='DELTA_FEATURES="+side-by-side" gsh'
|
||||
alias gsj="git stash"
|
||||
alias gsl="git stash list"
|
||||
alias gsm='git submodule'
|
||||
alias gsp="git stash pop"
|
||||
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'
|
||||
|
|
@ -188,6 +203,7 @@ alias dc!='d! compose'
|
|||
|
||||
alias di='d image'
|
||||
alias dj='dc up -d --force-recreate'
|
||||
alias djn='dc up -d'
|
||||
alias djb='dj --build'
|
||||
alias djbl='djb && dl'
|
||||
alias djl='dj && dl'
|
||||
|
|
@ -197,16 +213,38 @@ alias dr='d run --rm -it'
|
|||
alias drs='dc restart'
|
||||
alias drsl='dc restart && dl'
|
||||
alias dv='d volume'
|
||||
alias ds='dc stop'
|
||||
|
||||
# tmux stuff
|
||||
tn() { tmux new-session -s "${1-"$(basename "$(pwd)")"}" }
|
||||
alias ta='tmux a -t'
|
||||
# ta() { tmux a -t "$1" }; compdef '_tmux; _tmux-attach-session' ta
|
||||
ta() { tmux a -t "$1" }
|
||||
# alias ta='tmux a -t'
|
||||
|
||||
# disable xon control chars
|
||||
stty -ixon
|
||||
|
||||
# print tasks on startup
|
||||
_ZSH_TODO_FILE="${HOME}/todo.md"
|
||||
[ -f "$_ZSH_TODO_FILE" ] && { cat "$_ZSH_TODO_FILE" | grep -v '>.*'; }
|
||||
unset _ZSH_TODO_FILE
|
||||
TODO_FILE="${HOME}/todo.md"
|
||||
[ -f "$TODO_FILE" ] && { cat "$TODO_FILE" | grep -v '>.*'; }
|
||||
unset TODO_FILE
|
||||
|
||||
setopt extendedglob
|
||||
autoload add-zsh-hook
|
||||
for file in "$ZDOTDIR/cd_hooks/"^_*; do
|
||||
fname="cd_::$(basename "$file")"
|
||||
eval "
|
||||
$fname() {
|
||||
$(cat "$file")"'
|
||||
if [ -n "$DIRNAME" ]; then
|
||||
if [[ "$PWD/" = "$DIRNAME"*/ && ( "$OLDPWD/" != "$DIRNAME"*/ || "$PWD" = "$OLDPWD" ) ]]; then cd::enter
|
||||
elif [[ "$PWD/" != "$DIRNAME"*/ && "$OLDPWD/" = "$DIRNAME"*/ ]]; then cd::leave; fi
|
||||
elif [ -n "$BASE_DIR" ]; then
|
||||
: # TODO: handle
|
||||
fi
|
||||
}
|
||||
'
|
||||
add-zsh-hook chpwd "$fname"
|
||||
"$fname"
|
||||
done
|
||||
unsetopt extendedglob
|
||||
CD_HOOKS_COMPLETED=1
|
||||
|
|
|
|||
13
.config/zsh/cd_hooks/hicpu_mount
Normal file
13
.config/zsh/cd_hooks/hicpu_mount
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# shellcheck disable=SC2164,SC2168
|
||||
|
||||
local DIRNAME="$HOME/Services/cpu"
|
||||
|
||||
cd::enter() {
|
||||
! mount | grep -q "$DIRNAME" && mount "$DIRNAME" && builtin cd -q "$DIRNAME"
|
||||
}
|
||||
|
||||
cd::leave() {
|
||||
! fuser -m "$DIRNAME" >/dev/null 2>&1 && umount "$DIRNAME"
|
||||
}
|
||||
|
||||
# vim: ft=sh
|
||||
14
.config/zsh/cd_hooks/higpu_mount
Normal file
14
.config/zsh/cd_hooks/higpu_mount
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# shellcheck disable=SC2168
|
||||
|
||||
local DIRNAME="$HOME/Services/gpu"
|
||||
local MOUNT_DIRNAME="$DIRNAME/.volumes"
|
||||
|
||||
cd::enter() {
|
||||
! mount | grep -q "$MOUNT_DIRNAME" && mount "$MOUNT_DIRNAME"
|
||||
}
|
||||
|
||||
cd::leave() {
|
||||
! fuser "$DIRNAME" >/dev/null 2>&1 && umount "$MOUNT_DIRNAME"
|
||||
}
|
||||
|
||||
# vim: ft=sh
|
||||
73
.config/zsh/cd_hooks/university
Normal file
73
.config/zsh/cd_hooks/university
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
local DIRNAME="$HOME/University/"
|
||||
|
||||
mode::enable() {
|
||||
local mode_path="$DIRNAME/$1/.env"
|
||||
export MODE__ACTIVE_MODE="$1"
|
||||
export MODE__OLD_PS1="$PS1"
|
||||
|
||||
export PS1="($1) $PS1"
|
||||
|
||||
. "$mode_path"
|
||||
}
|
||||
|
||||
|
||||
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]+)=(.*)\n/ && print "$1=$2\n"' < "$1"
|
||||
}
|
||||
|
||||
mode::disable() {
|
||||
export PS1="$MODE__OLD_PS1"
|
||||
local mode_path="$DIRNAME/$MODE__ACTIVE_MODE/.env"
|
||||
|
||||
unset -v "MODE__OLD_PS1"
|
||||
unset -v "MODE__ACTIVE_MODE"
|
||||
|
||||
for mode_variable in ${(@f)"$(mode::get_variables "$mode_path")"}; do
|
||||
unset "$mode_variable"
|
||||
done
|
||||
|
||||
for mode_function in ${(@f)"$(mode::get_functions "$mode_path")"}; do
|
||||
unset -f "$mode_function"
|
||||
done
|
||||
|
||||
for mode_alias in ${(@f)"$(mode::get_aliases "$mode_path")"}; do
|
||||
unalias "${mode_alias%=*}"
|
||||
done
|
||||
}
|
||||
|
||||
cd::enter() {
|
||||
[ -n "$MODE__ACTIVE_MODE" ] && mode::disable
|
||||
local module_name="$(cut -d/ -f1 <<<"${PWD#"$DIRNAME"}" )"
|
||||
[ ! -f "$DIRNAME/$module_name/.env" ] && return
|
||||
mode::enable "$module_name"
|
||||
}
|
||||
|
||||
cd::leave() {
|
||||
[ -n "$MODE__ACTIVE_MODE" ] && mode::disable
|
||||
}
|
||||
|
||||
m() {
|
||||
[ -z "$MODE__ACTIVE_MODE" ] && return 1
|
||||
|
||||
local mode_path="$DIRNAME/$MODE__ACTIVE_MODE/.env"
|
||||
|
||||
for type in Aliases Functions Variables; do
|
||||
local arr=(${(@f)"$(mode::get_"${type:l}" "$mode_path")"})
|
||||
|
||||
[ "${#arr}" -gt 0 ] && {
|
||||
echo "$type:"
|
||||
printf '%s\n' "${arr[@]}"
|
||||
echo
|
||||
}
|
||||
done | head -n -1
|
||||
}
|
||||
|
||||
# vim: ft=zsh
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
#!/usr/bin/zsh
|
||||
|
||||
mode::enable() {
|
||||
local mode_path="${HOME}/.config/zsh/modes/$1.sh"
|
||||
[ ! -f "$mode_path" ] && echo "Mode not found!" && return 1
|
||||
export MODE__ACTIVE_MODE="$1"
|
||||
|
||||
export MODE__OLD_PS1="$PS1"
|
||||
export PS1="($1) $PS1"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
source "$mode_path"
|
||||
}
|
||||
|
||||
|
||||
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"
|
||||
|
||||
unset -v "MODE__OLD_PS1"
|
||||
unset -v "MODE__ACTIVE_MODE"
|
||||
|
||||
for mode_variable in $(mode::get_variables "$mode_path"); do
|
||||
unset "$mode_variable"
|
||||
done
|
||||
|
||||
for mode_function in $(mode::get_functions "$mode_path"); do
|
||||
unset -f "$mode_function"
|
||||
done
|
||||
|
||||
for mode_alias in $(mode::get_aliases "$mode_path"); do
|
||||
unalias "$mode_alias"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
mode::help() {
|
||||
echo "Usage:"
|
||||
echo " mode <MODENAME>"
|
||||
echo
|
||||
echo "Available modes:"
|
||||
for mode in ~/.config/zsh/modes/*; do
|
||||
printf " %s\n" "$(basename "${mode%.sh}")"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
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 "$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
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# shellcheck disable=SC2139
|
||||
|
||||
CPP_MODE__BUILD_DIR="./cmake-build"
|
||||
|
||||
alias cb="cmake --build ${CPP_MODE__BUILD_DIR}"
|
||||
alias cg="cmake -B ${CPP_MODE__BUILD_DIR} -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && ln -sf ${CPP_MODE__BUILD_DIR}/compile_commands.json ."
|
||||
|
||||
cpp_mode::find_exec() {
|
||||
find "${CPP_MODE__BUILD_DIR}/$1" -maxdepth 1 -type f -executable
|
||||
}
|
||||
|
||||
ct() {
|
||||
"$(cpp_mode::find_exec "tests")"
|
||||
}
|
||||
|
||||
cr() {
|
||||
"$(cpp_mode::find_exec)"
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
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'
|
||||
Loading…
Add table
Add a link
Reference in a new issue