205 lines
4.5 KiB
Bash
205 lines
4.5 KiB
Bash
#
|
|
# ~/.zshrc
|
|
#
|
|
|
|
# If not running interactively, do nothing
|
|
[[ $- != *i* ]] && return
|
|
|
|
export PATH="$HOME/.local/share/flatpak/exports/bin:$HOME/.local/bin:$PATH"
|
|
export ZSH=$HOME/.oh-my-zsh
|
|
|
|
ZSH_THEME=spaceship
|
|
HYPHEN_INSENSITIVE=true
|
|
ENABLE_CORRECTION=true
|
|
|
|
# Display red dots whilst waiting for completion
|
|
COMPLETION_WAITING_DOTS=true
|
|
|
|
# Timestamps for history
|
|
HIST_STAMPS=yyyy-mm-dd
|
|
|
|
plugins=(
|
|
colored-man-pages
|
|
copybuffer
|
|
docker
|
|
docker-compose
|
|
git
|
|
git-extras
|
|
helm
|
|
kubectl
|
|
ripgrep
|
|
rust
|
|
safe-paste
|
|
sudo
|
|
z
|
|
|
|
# must be last
|
|
zsh-syntax-highlighting
|
|
)
|
|
|
|
source $ZSH/oh-my-zsh.sh
|
|
|
|
# Show low battery warning < 20% left
|
|
SPACESHIP_BATTERY_THRESHOLD=20
|
|
|
|
# Show execution time of last command if > 10 sec
|
|
SPACESHIP_EXEC_TIME_ELAPSED=10
|
|
|
|
SPACESHIP_EXIT_CODE_SYMBOL="✘ "
|
|
SPACESHIP_EXIT_CODE_SHOW=true
|
|
SPACESHIP_TIME_SHOW=true
|
|
|
|
SPACESHIP_USER_SHOW=needed
|
|
|
|
export HISTCONTROL=ignoreboth
|
|
export HISTSIZE=10000
|
|
export HISTFILESIZE=$HISTSIZE
|
|
|
|
export MANPATH="/usr/local/man:$MANPATH"
|
|
export LC_ALL=$LANG
|
|
|
|
export EDITOR=amp
|
|
export GIT_EDITOR=$EDITOR
|
|
export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig:$HOME/.local/share/pkgconfig:/usr/local/lib/pkgconfig"
|
|
export GEM_HOME=$HOME/.gem
|
|
export PATH="$GEM_HOME/bin:$PATH"
|
|
|
|
# Golang
|
|
export GOPATH=$HOME/.go
|
|
export PATH="$GOPATH/bin:$PATH"
|
|
|
|
export GPG_TTY=$(tty)
|
|
|
|
export VAGRANT_DEFAULT_PROVIDER=libvirt
|
|
|
|
if [ -z "$SSH_CLIENT" ]; then
|
|
# Setup base16 themes only on local sessions
|
|
export BASE16_SHELL=$HOME/.config/base16-shell
|
|
[ -n "$PS1" ] && [ -s $BASE16_SHELL/profile_helper.sh ] && eval "$($BASE16_SHELL/profile_helper.sh)"
|
|
fi
|
|
|
|
# Setup nvm
|
|
export NVM_DIR=$HOME/.nvm
|
|
[ -s $NVM_DIR/nvm.sh ] && source $NVM_DIR/nvm.sh
|
|
|
|
# Do not freeze terminal on Ctrl-S
|
|
stty -ixon
|
|
|
|
# Do not share history
|
|
unsetopt share_history
|
|
|
|
# Disable annoying correction prompt
|
|
unsetopt correct_all
|
|
|
|
# Additional keybinds
|
|
bindkey '^H' backward-kill-word
|
|
|
|
# Git
|
|
alias gc='git commit --verbose --signoff'
|
|
alias gcan!='git commit --verbose --signoff --amend --date now --reset-author'
|
|
|
|
# Makefile
|
|
alias m='make'
|
|
|
|
# Rust
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
alias cb='cargo build'
|
|
alias cr='cargo run'
|
|
alias ccl='cargo clippy'
|
|
|
|
# PostgreSQL
|
|
alias lpsql='psql -U postgres -h localhost'
|
|
|
|
# Misc
|
|
alias diff='diff -u -p -r -N --color=auto'
|
|
alias open=xdg-open
|
|
alias usystemctl='systemctl --user'
|
|
alias valgrind-full-check='valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes'
|
|
alias weather='curl wttr.in'
|
|
alias yt-dl-mp3="youtube-dl -o '%(title)s.%(ext)s' -i -x --audio-quality 320K --audio-format mp3"
|
|
alias yt-dl-video="youtube-dl -iw -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best'"
|
|
|
|
git-check-merge() {
|
|
local output="$(git merge $1 --no-ff --no-commit 2>&1)"
|
|
|
|
if [[ "$output" == *"merge failed"* ]]; then
|
|
echo "$output" | grep CONFLICT 2>/dev/null
|
|
echo "Automatic merge failed" 2>/dev/null
|
|
else
|
|
echo "Automatic merge went well"
|
|
fi
|
|
|
|
git merge --abort # Return to previous state
|
|
}
|
|
|
|
gen-rsa-keypair() {
|
|
openssl genpkey -algorithm RSA -out "$1" -pkeyopt rsa_keygen_bits:4096
|
|
openssl rsa -pubout -in "$1" -out "$1.pub"
|
|
}
|
|
|
|
allow-any-ptrace() {
|
|
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope >/dev/null
|
|
}
|
|
|
|
deny-any-ptrace() {
|
|
echo 1 | sudo tee /proc/sys/kernel/yama/ptrace_scope >/dev/null
|
|
}
|
|
|
|
__update_log() {
|
|
printf "\n 📦 \e[92mUpdating $1\e[0m\n"
|
|
}
|
|
|
|
__update_system_packages() {
|
|
if [ -f /etc/arch-release ]; then
|
|
yay -Syu --sudoloop --noconfirm --nodiffmenu --noeditmenu --noupgrademenu
|
|
yay -Yc --noconfirm # Clean unneeeded dependencies
|
|
yes y | yay -Scc
|
|
elif [ -f /etc/fedora-release ]; then
|
|
sudo dnf upgrade --assumeyes
|
|
sudo dnf clean packages
|
|
fi
|
|
}
|
|
|
|
__update_git_repo() {
|
|
pushd "$1"
|
|
git pull
|
|
popd
|
|
}
|
|
|
|
update() {
|
|
setopt pushdsilent
|
|
|
|
__update_log 'system packages'
|
|
__update_system_packages
|
|
|
|
if hash flatpak 2> /dev/null; then
|
|
__update_log 'flatpak apps'
|
|
flatpak update -y
|
|
fi
|
|
|
|
if hash yarn 2> /dev/null; then
|
|
__update_log 'global node packages'
|
|
yarn global upgrade
|
|
fi
|
|
|
|
if hash gem 2> /dev/null; then
|
|
__update_log gems
|
|
gem update
|
|
fi
|
|
|
|
if hash rustup 2> /dev/null; then
|
|
__update_log rust
|
|
rustup update
|
|
fi
|
|
|
|
__update_log 'oh-my-zsh'
|
|
omz update --unattended
|
|
|
|
__update_log 'oh-my-zsh extra stuff'
|
|
__update_git_repo "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
|
|
__update_git_repo "$ZSH_CUSTOM/themes/spaceship-prompt"
|
|
__update_git_repo "$HOME/.config/base16-shell"
|
|
|
|
unsetopt pushdsilent
|
|
}
|