Files
dotfiles/.zshrc
2025-07-06 18:04:51 +03:00

149 lines
4.6 KiB
Bash

# Enable Powerlevel10k instant prompt
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Path to your oh-my-zsh installation.
ZSH=/usr/share/oh-my-zsh/
# Path to powerlevel10k theme
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme
# List of plugins used
plugins=( git sudo zsh-256color zsh-autosuggestions zsh-syntax-highlighting )
source $ZSH/oh-my-zsh.sh
# In case a command is not found, try to find the package that has it
function command_not_found_handler {
local purple='\e[1;35m' bright='\e[0;1m' green='\e[1;32m' reset='\e[0m'
printf 'zsh: command not found: %s\n' "$1"
local entries=( ${(f)"$(/usr/bin/pacman -F --machinereadable -- "/usr/bin/$1")"} )
if (( ${#entries[@]} )) ; then
printf "${bright}$1${reset} may be found in the following packages:\n"
local pkg
for entry in "${entries[@]}" ; do
local fields=( ${(0)entry} )
if [[ "$pkg" != "${fields[2]}" ]] ; then
printf "${purple}%s/${bright}%s ${green}%s${reset}\n" "${fields[1]}" "${fields[2]}" "${fields[3]}"
fi
printf ' /%s\n' "${fields[4]}"
pkg="${fields[2]}"
done
fi
return 127
}
# Detect the AUR wrapper
if pacman -Qi yay &>/dev/null ; then
aurhelper="yay"
elif pacman -Qi paru &>/dev/null ; then
aurhelper="paru"
fi
# Cache AUR helper detection
if [[ -z "$aurhelper" ]]; then
if command -v yay >/dev/null 2>&1; then
export aurhelper="yay"
elif command -v paru >/dev/null 2>&1; then
export aurhelper="paru"
fi
fi
function in {
local -a inPkg=("$@")
local -a arch=()
local -a aur=()
for pkg in "${inPkg[@]}"; do
if pacman -Si "${pkg}" &>/dev/null ; then
arch+=("${pkg}")
else
aur+=("${pkg}")
fi
done
if [[ ${#arch[@]} -gt 0 ]]; then
sudo pacman -S "${arch[@]}"
fi
if [[ ${#aur[@]} -gt 0 ]]; then
${aurhelper} -S "${aur[@]}"
fi
}
# Helpful aliases
alias c='clear' # clear terminal
alias l='eza -1h --icons=auto --sort=name --group-directories-first' # long list
alias ls='eza -l --icons=auto --sort=name --group-directories-first' # short list
alias ll='eza -lha --icons=auto --sort=name --group-directories-first' # long list all
alias дд='eza -lha --icons=auto --sort=name --group-directories-first' # sometimes i forget to change keyboard layout
alias lt='eza --icons=auto --tree' # list folder as tree
alias un='$aurhelper -Rns' # uninstall package
alias up='$aurhelper -Syu' # update system/package/aur
alias pl='$aurhelper -Qs' # list installed package
alias pa='$aurhelper -Ss' # list available package
alias pc='$aurhelper -Sc' # remove unused cache
alias po='$aurhelper -Qtdq | $aurhelper -Rns -' # remove unused packages, also try > $aurhelper -Qqd | $aurhelper -Rsu --print -
alias icat='kitten icat' # display images in terminal
alias ssh='kitten ssh' # functional ssh with kitty
alias snv='sudo -E nvim' # sudo nvim
alias nv='nvim'
alias ff='fastfetch'
alias pi='ssh omoelle'
alias pi-mount='sshfs omoelle:/home/elleoma ~/mnt && cd ~/mnt'
alias cat='bat --paging=never'
alias wifi="nmcli d wifi show-password | grep 'Password' | awk -F': ' '{ print \$2 }'"
alias pivpn="wg-quick up laptop"
alias config='git --git-dir=/home/elleoma/.config --work-tree=/home/elleoma'
# git aliases
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias gco='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'
alias got='git '
alias get='git '
alias gut='git '
# Handy change dir shortcuts
alias ..='cd ..'
alias ...='cd ../..'
alias .3='cd ../../..'
alias .4='cd ../../../..'
alias .5='cd ../../../../..'
# Alias for cross-compile to windows
#alias x86_64-w64-mingw32-g++='mingw'
# Always mkdir a path (this doesn't inhibit functionality to make a single dir)
alias mkdir='mkdir -p'
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Syntax highlighting for man pages
export MANPAGER='nvim +Man!'
# Setting Ruby path
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"
# Created by `pipx` on 2025-02-01 15:08:39
export PATH="$PATH:/home/elleoma/.local/bin"
# Setting up Rust
export PATH="$HOME/.cargo/bin:$PATH"
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
export PATH=~/.npm-global/bin:$PATH
# go binaries path
export PATH=~/go/bin:$PATH