Files
opalfiles/.config/zsh/.zshrc
2026-04-06 10:06:15 -07:00

174 lines
4.1 KiB
Bash

#######################################################
# GENERAL
#######################################################
setopt HIST_VERIFY # Confirm !! and similar before executing
autoload -Uz compinit
compinit
export PATH="$PATH:$HOME/.local/bin"
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit
compinit
export EDITOR="nvim"
HISTFILE=$ZDOTDIR/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
# Options to make history nicer
setopt HIST_IGNORE_DUPS HIST_IGNORE_SPACE
# Auto capitalize
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
#######################################################
# KEYBINDS
#######################################################
autoload -U select-word-style
select-word-style bash
bindkey '^[[1;3D' backward-word # Alt+Left
bindkey '^[[1;3C' forward-word # Alt+Right
#######################################################
# PROMPT
#######################################################
setopt prompt_subst # allow ${...} inside PROMPT to expand
autoload -Uz vcs_info
precmd() { vcs_info } # refresh git info before each prompt
# vcs_info (git branch in parentheses)
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git:*' formats ' (%b)'
# optional: hide the default end-of-line % sign on errors
PROMPT_EOL_MARK=''
PROMPT='%F{cyan}[%n@%m %F{yellow}%~%f%F{green}${vcs_info_msg_0_}%f%F{cyan}]%f
%# '
# Remove right side prompt (like time)
unset RPROMPT
#######################################################
# ALIAS
#######################################################
alias dot='cd ~/Code/opalfiles'
alias ans='cd ~/Code/ansible'
alias v='nvim'
alias vim='nvim'
alias vi='nvim'
# Package Manager
alias pin='sudo pacman -S'
alias pre='sudo pacman -R'
alias pup='sudo pacman -Syu'
alias pse='pacman -Ss'
# alias to show the date
alias da='date "+%Y-%m-%d %A %T %Z"'
# Alias's to modified commands
alias cp='cp -i'
alias mv='mv -i'
alias mkdir='mkdir -p'
alias ps='ps auxf'
alias ping='ping -c 10'
alias less='less -R'
# cd into the old directory
alias bd='cd "$OLDPWD"'
# Search command line history
alias h="history | grep "
# Search files in the current folder
alias f="find . | grep "
# Alias's to show disk space and space used in a folder
alias diskspace="du -S | sort -n -r |more"
alias folders='du -h --max-depth=1'
alias folderssort='find . -maxdepth 1 -type d -print0 | xargs -0 du -sk | sort -rn'
alias tree='tree -CAhF --dirsfirst'
alias treed='tree -CAFd'
alias mountedinfo='df -hT'
# Alias's for archives
alias mktar='tar -cvf'
alias mkbz2='tar -cvjf'
alias mgz='tar -cvzf'
alias untar='tar -xvf'
alias unbz2='tar -xvjf'
alias ungz='tar -xvzf'
# Wget (keeps hsts files out of $HOME)
alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"'
# Translate
alias tbr='trans :pt-BR'
# ncmpcpp
alias ncmpcpp='ncmpcpp -b ~/.config/ncmpcpp/bindings'
# ls
alias ll='ls -l --color=auto'
alias la='ls -la --color=auto'
# git
alias gs='git status'
alias ga='git add'
alias gpull='git pull'
alias gcom='git commit -m'
alias h='history 1'
alias pkg='nvim ~/Code/arch-ansible/roles/packages/tasks/main.yml'
alias pkg-aur='nvim ~/Code/arch-ansible/scripts/aur-pkg-install.sh'
# Wireguard
alias wgup='nmcli connection up wg0'
alias wgdown='nmcli connection down wg0'
#######################################################
# FUNCTIONS
#######################################################
apply() {
(cd ~/Code/arch-ansible && ansible-playbook -i inventory/hosts.yml site.yml -K "$@")
}
apply-aur() {
(cd ~/Code/arch-ansible/scripts && bash aur-pkg-install.sh)
}
shred-dir() {
local dir="${1:?Usage: shred-dir <directory>}"
local passes="${2:-7}"
[[ ! -d "$dir" ]] && { echo "Not a directory: '$dir'"; return 1; }
echo "Shred '$dir' with $passes passes? [y/N]"
read -r confirm
[[ "$confirm" != [yY] ]] && { echo "Aborted."; return 1; }
find "$dir" -type f -exec shred -uz -n "$passes" {} \;
rm -rf "$dir"
echo "Done."
}
keys()
{
eval "$(keychain --quiet --absolute --dir ~/.config/keychain --eval ry_ecdsa)"
eval "$(keychain --quiet --absolute --dir ~/.config/keychain --eval id_rsa)"
}
keys