Refactor dotfiles - 2026-01-18

Changes:
- Refactored .zshrc into modular oh-my-zsh/custom/ files
- Created aliases.zsh, functions.zsh, path.zsh, keybindings.zsh
- Added bira-time.zsh-theme (bira with timestamp)
- Added tools/*.zsh for pyenv, nvm, kubectl
- Updated .tmux.conf.local with cross-platform support
- Updated gpakosz/.tmux framework
- Cleaned up .zshenv
This commit is contained in:
Viktor Barzin 2026-01-18 14:23:48 +00:00
parent 58ef6d327f
commit 47120112ad
12 changed files with 811 additions and 453 deletions

View file

@ -0,0 +1,154 @@
# Aliases - organized by category
# Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/
# ============================================================================
# Basic utilities
# ============================================================================
alias ls='ls --color=auto'
alias sl=ls
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias vi="vim"
alias vimdiff="vim -d"
alias vix="vim -X" # Fast vim startup without X (no system clipboard)
alias vimrc="vim ~/.vimrc"
alias zshrc="vim ~/.zshrc"
alias sizeof='du -sh'
alias mkdir="mkdir -pv"
alias f="free -h"
alias h="sudo htop"
alias a="sudo atop"
alias e="exa -bghHliS"
alias n="sudo nethogs"
alias i="sudo iotop"
alias hosts="sudo vim /etc/hosts"
alias root="sudo su -"
alias xo="xdg-open"
alias time='"time"' # Disable bash builtin
alias toclip="xclip -selection clipboard"
# ============================================================================
# Python
# ============================================================================
alias py='python3'
alias ipy='ipython3'
alias pmr='python manage.py runserver'
alias nopmr="ps auxw | grep runserver | awk '{print \$2}' | xargs kill"
alias pmm='python manage.py migrate'
alias pmmm='python manage.py makemigrations'
# ============================================================================
# Git
# ============================================================================
alias g='git'
alias gs='git status'
alias ga='git add'
alias gc='git commit -S'
alias gp='git push origin master'
alias gpf='git push -u forgejo master'
alias gpull='git pull --rebase origin master'
alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
alias gd="git diff"
alias gds="git diff --staged"
alias gb="git branch"
alias gpp='git push production master'
alias git-pull-branches='git branch -r | grep -v "\->" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done'
# ============================================================================
# Docker
# ============================================================================
alias dk="docker"
alias dsl="docker swarm leave --force"
alias dkon="sudo systemctl start docker"
alias dkoff="sudo systemctl stop docker"
# ============================================================================
# Kubernetes
# ============================================================================
alias kb="kubectl"
alias kbp="kubectl get pods"
alias kbpo="kubectl get pods -o wide"
alias kbs="kubectl get svc"
alias kbn="kubectl get nodes -o wide"
alias kbd="kubectl describe pods"
alias kbf="kubectl logs --all-containers --max-log-requests 50 -f --since=5m"
alias kbe='kubectl exec -it $(kbp | tail -n 1 | awk "{print \$1}") -- sh'
alias kn="kubens"
# ============================================================================
# Terraform
# ============================================================================
alias tf="terraform"
alias tfa="tf apply"
# ============================================================================
# Network
# ============================================================================
alias s="ssh"
alias myip="curl https://icanhazip.com"
alias ifl="ifconfig|less"
alias whatisopen='sudo netstat -pnlt'
alias speedtest="curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -"
alias wg="sudo wg"
# ============================================================================
# System
# ============================================================================
alias omg="sudo systemctl restart NetworkManager"
alias omg1.1="sudo rmmod iwlmvm && sudo rmmod iwlwifi; sudo modprobe iwlwifi"
alias omg2="kwin --replace &"
alias omg2.1="kquitapp5 plasmashell && kstart5 plasmashell"
alias battery="upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E 'time to empty|state|to\ full|percentage'"
alias bye="sudo systemctl suspend"
alias hib="sudo systemctl hibernate"
alias gg="xset dpms force off"
alias wa="watch sensors"
alias gtop="sudo intel_gpu_top"
alias vmon="sudo systemctl start vmware"
alias vmoff="sudo systemctl stop vmware"
# ============================================================================
# Misc tools
# ============================================================================
alias aliases="vim ~/.oh-my-zsh/custom/aliases.zsh && source ~/.zshrc"
alias rmswp="find ~/.vim/tmp/ -iname \"*swp\" -delete"
alias clearsessions="rm -rf ~/.vim/tmp/sessions/*"
alias zsh_fix="mv ~/.zsh_history ~/.zsh_history_bad; strings ~/.zsh_history_bad > ~/.zsh_history; fc -R ~/.zsh_history; rm ~/.zsh_history_bad"
alias server="/opt/miniserve-linux"
alias gr="go run ."
alias hg="hugo -D server --bind 0.0.0.0"
alias cr="cargo run"
alias tricks="vi ~/tricks/tricks.txt"
alias logout="qdbus org.kde.ksmserver /KSMServer logout 0 0 0"
# Shadowsocks
alias ss-tunnel="snap run shadowsocks-libev.ss-tunnel"
alias ss-local="snap run shadowsocks-libev.ss-local"
# ============================================================================
# Package manager detection (for update/install aliases)
# ============================================================================
typeset -A osInfo
osInfo[/etc/redhat-release]=dnf
osInfo[/etc/arch-release]=pacman
osInfo[/etc/gentoo-release]=emerge
osInfo[/etc/SuSE-release]=zypp
osInfo[/etc/debian_version]=apt-get
for f in "${(@k)osInfo}"; do
if [[ -f $f ]]; then
pm=${osInfo[$f]}
fi
done
alias update="sudo $pm update"
alias u="update"
alias upgrade="sudo $pm upgrade"
alias install="sudo $pm install"
alias remove="sudo $pm remove"
alias reinstall="sudo $pm reinstall"

View file

@ -0,0 +1,167 @@
# Shell functions
# Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/
# ============================================================================
# Git functions
# ============================================================================
# Useful for daily stand-up
git-standup() {
AUTHOR=${AUTHOR:="$(git config user.name)"}
since=yesterday
if [[ $(date +%u) == 1 ]]; then
since="2 days ago"
fi
git log --all --since "$since" --oneline --author="$AUTHOR"
}
# ============================================================================
# Network functions
# ============================================================================
netok() {
echo 'Testing DNS settings.'
timeout 1 ping google.com -W 1 -c 1 &>> /dev/null
if (( $? == 0 )); then
echo 'Internet is up.'
return 0
fi
echo 'Pinging 8.8.8.8'
ping 8.8.8.8 -W 1 -c 1 &>> /dev/null
if (( $? == 0 )); then
echo 'Issue spotted in DNS settings'
return 0
fi
gateway=$(echo $(route -n | sed -n '3p' | awk '{print $2}'))
echo 'Pinging ' $gateway
ping $gateway -W 1 -c 2 &>> /dev/null
if (($? == 0 )); then
echo 'Gateway connectivity issues or being firewalled.'
return 0
else
echo 'Cannot reach default gateway.'
return 0
fi
}
certinfo() {
curl --insecure -v https://"$1" 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'
}
# ============================================================================
# Wireguard VPN
# ============================================================================
wgon() {
wg-quick up ~/vpn-certs/viktor.conf
# Add ipv4 precedence because vpn is v4 only for now
bash -c "grep -qxF 'precedence ::ffff:0:0/96 100' /etc/gai.conf || echo 'precedence ::ffff:0:0/96 100' | sudo tee -a /etc/gai.conf"
# Add dns if missing
ns_str="nameserver 10.0.20.1 # Added by wgon function"
search_str="search viktorbarzin.lan # Added by wgon function"
resolv_conf="/etc/resolv.conf"
bash -c "grep -qxF '$search_str' $resolv_conf || echo '$search_str' | sudo tee -a $resolv_conf"
bash -c "grep -qxF '$ns_str' $resolv_conf || echo '$ns_str' | sudo sed -i -e '1i $ns_str' $resolv_conf"
}
wgoff() {
wg-quick down ~/vpn-certs/viktor.conf
ns_str="nameserver 10.0.20.1 # Added by wgon function"
search_str="search viktorbarzin.lan # Added by wgon function"
resolv_conf="/etc/resolv.conf"
sudo sed -i '/precedence ::ffff:0:0\/96 100/d' /etc/gai.conf
sudo sed -i "/$search_str/d" $resolv_conf
sudo sed -i "/$ns_str/d" $resolv_conf
}
wgs() {
kubectl scale -n wireguard deployment wireguard --replicas=$1
}
# ============================================================================
# Kubernetes
# ============================================================================
cephpw() {
kubectl -n rook-ceph get secret rook-ceph-dashboard-password -o yaml | grep "password:" | grep -v '{}' | awk '{print $2}' | base64 --decode
}
kbop() {
kb -n rook-ceph delete pods $(kbp | grep opera | awk '{print $1}')
kb -n rook-ceph logs -f $(kbp | grep operator | awk '{print $1}')
}
# ============================================================================
# Compilation / Development
# ============================================================================
c() {
# Pass any arguments to gcc and afterwards run executable
gcc "$@" && ./a.out
}
dang_gcc() {
gcc "$@" -fno-stack-protector -z execstack
}
make_tags() {
avr-gcc -M $* | sed -e 's/[\\ ]/\n/g' | \
sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
}
# ============================================================================
# File encryption
# ============================================================================
encrypt() {
tar -czvf $1.tar.gz $1 && \
gpg --symmetric --armor $1.tar.gz && \
echo "Deleting $1 and $1.tar.gz" && \
rm -rf $1 $1.tar.gz
}
decrypt() {
gpg --decrypt $1 | tar xzvf -
}
# ============================================================================
# Utilities
# ============================================================================
camelcase() {
perl -pe 's#(_|^)(.)#\u$2#g'
}
waitfor() {
while pidof $1 > /dev/null; do sleep 2; done
}
b64() {
echo $1 | base64 -d
}
# Include helper - source file if it exists
include() {
[[ -f "$1" ]] && source "$1"
}
# Download GitHub folder using svn
download_github_folder() {
svn checkout $(echo $1 | sed "s/\/tree\/[a-zA-Z]\+/\/trunk/")
}
alias svali_papka=download_github_folder
# Snapper wrapper for btrfs snapshots
snp() {
cmd="$@"
snapshot_nbr=$(snapper -c home create --type=pre --cleanup-algorithm=number --print-number --description="${cmd}")
eval "$cmd"
snapshot_nbr=$(snapper -c home create --type=post --cleanup-algorithm=number --print-number --pre-number="$snapshot_nbr")
}
alias sp="snapper -c home"
# YouTube playlist player
ytplaylist() {
youtube-dl -o - -f best $@ | vlc -
}

View file

@ -0,0 +1,13 @@
# Key bindings
# Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/
# Enable Ctrl-x-e to edit command line in $EDITOR
autoload -U edit-command-line
zle -N edit-command-line
bindkey '^xe' edit-command-line
bindkey '^x^e' edit-command-line
# Zsh autosuggestions (if plugin is installed)
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
bindkey '^[0' autosuggest-accept
bindkey '^[9' autosuggest-fetch

View file

@ -0,0 +1,18 @@
# PATH modifications
# Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/
# Go
export GOPATH="$HOME/go"
export PATH="$HOME/go/bin:$PATH"
# Local bin
export PATH="$HOME/.local/bin:$PATH"
# JDK (if installed)
[[ -d /opt/jdk-12.0.1/bin ]] && export PATH="/opt/jdk-12.0.1/bin:$PATH"
# Krew (kubectl plugin manager)
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
# Add custom zsh functions
fpath+=~/.zfunc

View file

@ -0,0 +1,36 @@
# bira-time theme - bira with timestamp
# Based on bira theme, adds current time to prompt
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host="%B%(!.%{$fg[red]%}.%{$fg[green]%})%n@%m%{$reset_color%} "
local user_symbol='%(!.#.$)'
local current_dir="%B%{$fg[blue]%}%~ %{$reset_color%}"
local current_time="%{$fg_bold[red]%}%*%{$reset_color%} "
local vcs_branch='$(git_prompt_info)$(hg_prompt_info)'
local rvm_ruby='$(ruby_prompt_info)'
local venv_prompt='$(virtualenv_prompt_info)'
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
PROMPT="╭─${user_host}${current_time}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt}
╰─%B${user_symbol}%b "
RPROMPT="%B${return_code}%b"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX=" %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}●%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[yellow]%}"
ZSH_THEME_HG_PROMPT_PREFIX="$ZSH_THEME_GIT_PROMPT_PREFIX"
ZSH_THEME_HG_PROMPT_SUFFIX="$ZSH_THEME_GIT_PROMPT_SUFFIX"
ZSH_THEME_HG_PROMPT_DIRTY="$ZSH_THEME_GIT_PROMPT_DIRTY"
ZSH_THEME_HG_PROMPT_CLEAN="$ZSH_THEME_GIT_PROMPT_CLEAN"
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}"
ZSH_THEME_RUBY_PROMPT_SUFFIX=" %{$reset_color%}"
ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX=" %{$reset_color%}"
ZSH_THEME_VIRTUALENV_PREFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_PREFIX"
ZSH_THEME_VIRTUALENV_SUFFIX="$ZSH_THEME_VIRTUAL_ENV_PROMPT_SUFFIX"

View file

@ -0,0 +1,10 @@
# Kubectl configuration
# Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/tools/
# Note: This must run after compinit, which oh-my-zsh handles
if command -v kubectl >/dev/null 2>&1; then
source <(kubectl completion zsh)
fi
# Load golang path if exists
[[ -f /etc/profile.d/golang_path.sh ]] && source /etc/profile.d/golang_path.sh

View file

@ -0,0 +1,6 @@
# NVM (Node Version Manager) configuration
# Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/tools/
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

View file

@ -0,0 +1,23 @@
# Pyenv configuration
# Auto-loaded by oh-my-zsh from $ZSH_CUSTOM/tools/
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv >/dev/null 2>&1; then
eval "$(pyenv init - zsh)"
fi
# Virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENV_PYTHON=python3
export WORKON_HOME=$HOME/.virtualenvs
if [[ -f /usr/local/bin/virtualenvwrapper.sh ]]; then
source /usr/local/bin/virtualenvwrapper.sh
elif [[ -f $HOME/.virtualenvwrapper.sh ]]; then
source $HOME/.virtualenvwrapper.sh
fi
# Python debugging
export PYTHONBREAKPOINT=ipdb.set_trace