2018-09-25 10:29:29 +02:00
|
|
|
#
|
|
|
|
# ~/.zshrc
|
|
|
|
#
|
|
|
|
|
|
|
|
# If not running interactively, do nothing
|
|
|
|
[[ $- != *i* ]] && return
|
|
|
|
|
2021-09-18 17:18:01 +02:00
|
|
|
export PATH="$HOME/.local/share/flatpak/exports/bin:$HOME/.local/bin:$PATH"
|
2018-09-25 10:29:29 +02:00
|
|
|
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=(
|
2019-05-09 21:52:26 +02:00
|
|
|
colored-man-pages
|
2021-05-15 00:06:43 +02:00
|
|
|
copybuffer
|
2018-09-25 10:29:29 +02:00
|
|
|
docker
|
2019-07-02 15:59:45 +02:00
|
|
|
docker-compose
|
2019-05-08 22:17:34 +02:00
|
|
|
git
|
2018-09-25 10:29:29 +02:00
|
|
|
git-extras
|
2021-05-15 00:30:22 +02:00
|
|
|
helm
|
|
|
|
kubectl
|
2022-08-24 13:00:56 +02:00
|
|
|
nomad
|
2021-05-15 00:06:43 +02:00
|
|
|
ripgrep
|
2021-12-29 14:22:22 +01:00
|
|
|
rust
|
2021-05-15 00:06:43 +02:00
|
|
|
safe-paste
|
2019-07-02 15:59:45 +02:00
|
|
|
sudo
|
2018-09-25 10:29:29 +02:00
|
|
|
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
|
2020-02-12 15:59:34 +01:00
|
|
|
SPACESHIP_TIME_SHOW=true
|
2018-09-25 10:29:29 +02:00
|
|
|
|
2021-08-23 18:13:14 +02:00
|
|
|
SPACESHIP_USER_SHOW=needed
|
|
|
|
|
2018-09-25 10:29:29 +02:00
|
|
|
export HISTCONTROL=ignoreboth
|
|
|
|
export HISTSIZE=10000
|
|
|
|
export HISTFILESIZE=$HISTSIZE
|
|
|
|
|
2021-09-18 17:18:45 +02:00
|
|
|
export MANPATH="/usr/local/man:$MANPATH"
|
|
|
|
export LC_ALL=$LANG
|
|
|
|
|
2022-04-27 13:37:54 +02:00
|
|
|
export EDITOR=vim
|
2018-09-25 10:29:29 +02:00
|
|
|
export GIT_EDITOR=$EDITOR
|
2020-11-13 19:31:56 +01:00
|
|
|
export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig:$HOME/.local/share/pkgconfig:/usr/local/lib/pkgconfig"
|
2020-02-11 23:52:22 +01:00
|
|
|
export GEM_HOME=$HOME/.gem
|
2020-11-13 19:31:56 +01:00
|
|
|
export PATH="$GEM_HOME/bin:$PATH"
|
2020-02-11 23:52:22 +01:00
|
|
|
|
2019-02-11 10:30:22 +01:00
|
|
|
export GPG_TTY=$(tty)
|
2021-08-25 16:37:55 +02:00
|
|
|
|
2021-09-18 17:18:01 +02:00
|
|
|
export VAGRANT_DEFAULT_PROVIDER=libvirt
|
|
|
|
|
2021-08-23 18:13:43 +02:00
|
|
|
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
|
2018-09-25 10:29:29 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2019-07-02 15:59:45 +02:00
|
|
|
# Do not share history
|
|
|
|
unsetopt share_history
|
|
|
|
|
2020-02-12 15:59:34 +01:00
|
|
|
# Disable annoying correction prompt
|
|
|
|
unsetopt correct_all
|
|
|
|
|
2021-11-16 17:23:30 +01:00
|
|
|
# Additional keybinds
|
|
|
|
bindkey '^H' backward-kill-word
|
|
|
|
|
2021-08-25 16:48:03 +02:00
|
|
|
# Git
|
|
|
|
alias gc='git commit --verbose --signoff'
|
|
|
|
alias gcan!='git commit --verbose --signoff --amend --date now --reset-author'
|
|
|
|
|
2022-03-07 18:04:27 +01:00
|
|
|
# Golang
|
|
|
|
export GOPATH=$HOME/.go
|
|
|
|
export PATH="$GOPATH/bin:$PATH"
|
|
|
|
|
2021-09-18 14:43:39 +02:00
|
|
|
# Makefile
|
|
|
|
alias m='make'
|
|
|
|
|
2021-08-25 16:48:03 +02:00
|
|
|
# Rust
|
2021-09-18 17:18:01 +02:00
|
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
2021-08-25 16:48:03 +02:00
|
|
|
alias cb='cargo build'
|
2022-04-27 13:38:22 +02:00
|
|
|
alias cnb='cargo +nightly build'
|
2021-08-25 16:48:03 +02:00
|
|
|
alias cr='cargo run'
|
2022-04-27 13:38:22 +02:00
|
|
|
alias cnr='cargo +nightly run'
|
2021-08-25 16:48:03 +02:00
|
|
|
alias ccl='cargo clippy'
|
|
|
|
|
2022-03-07 18:03:16 +01:00
|
|
|
# PostgreSQL
|
|
|
|
alias lpsql='psql -U postgres -h localhost'
|
|
|
|
|
2021-08-25 16:48:03 +02:00
|
|
|
# Misc
|
2020-10-26 14:28:57 +01:00
|
|
|
alias diff='diff -u -p -r -N --color=auto'
|
2022-08-12 14:57:29 +02:00
|
|
|
alias journalctl-clean='journalctl --vacuum-time=7d'
|
2021-09-18 17:18:01 +02:00
|
|
|
alias open=xdg-open
|
2022-08-12 14:57:29 +02:00
|
|
|
alias sudo='sudo '
|
2021-09-18 17:18:01 +02:00
|
|
|
alias usystemctl='systemctl --user'
|
2022-03-07 18:03:30 +01:00
|
|
|
alias valgrind-full-check='valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --num-callers=256'
|
2021-09-18 17:18:01 +02:00
|
|
|
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'"
|
2021-05-15 00:25:49 +02:00
|
|
|
|
2019-07-03 12:59:00 +02:00
|
|
|
git-check-merge() {
|
2019-08-02 18:16:46 +02:00
|
|
|
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
|
|
|
|
|
2019-07-03 12:59:00 +02:00
|
|
|
git merge --abort # Return to previous state
|
|
|
|
}
|
|
|
|
|
2019-07-19 11:23:00 +02:00
|
|
|
gen-rsa-keypair() {
|
|
|
|
openssl genpkey -algorithm RSA -out "$1" -pkeyopt rsa_keygen_bits:4096
|
|
|
|
openssl rsa -pubout -in "$1" -out "$1.pub"
|
|
|
|
}
|
|
|
|
|
2021-09-18 17:18:01 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-09-25 10:29:29 +02:00
|
|
|
__update_log() {
|
|
|
|
printf "\n 📦 \e[92mUpdating $1\e[0m\n"
|
|
|
|
}
|
|
|
|
|
2021-09-18 17:18:01 +02:00
|
|
|
__update_system_packages() {
|
|
|
|
if [ -f /etc/arch-release ]; then
|
|
|
|
yay -Syu --sudoloop --noconfirm --nodiffmenu --noeditmenu --noupgrademenu
|
|
|
|
yay -Yc --noconfirm # Clean unneeeded dependencies
|
2021-09-19 13:12:47 +02:00
|
|
|
yes y | yay -Scc
|
2021-09-18 17:18:01 +02:00
|
|
|
elif [ -f /etc/fedora-release ]; then
|
|
|
|
sudo dnf upgrade --assumeyes
|
|
|
|
sudo dnf clean packages
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-03-11 08:41:10 +01:00
|
|
|
__update_git_repo() {
|
|
|
|
pushd "$1"
|
2019-07-21 16:57:55 +02:00
|
|
|
git pull
|
|
|
|
popd
|
|
|
|
}
|
2018-09-25 10:29:29 +02:00
|
|
|
|
|
|
|
update() {
|
2021-03-11 08:41:10 +01:00
|
|
|
setopt pushdsilent
|
|
|
|
|
2018-09-25 10:29:29 +02:00
|
|
|
__update_log 'system packages'
|
2021-09-18 17:18:01 +02:00
|
|
|
__update_system_packages
|
|
|
|
|
|
|
|
if hash flatpak 2> /dev/null; then
|
|
|
|
__update_log 'flatpak apps'
|
|
|
|
flatpak update -y
|
2022-08-12 14:57:55 +02:00
|
|
|
flatpak remove -y --unused
|
2021-09-18 17:18:01 +02:00
|
|
|
fi
|
2018-09-25 10:29:29 +02:00
|
|
|
|
|
|
|
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
|
2019-07-21 16:57:55 +02:00
|
|
|
|
2020-11-30 12:22:43 +01:00
|
|
|
__update_log 'oh-my-zsh'
|
2021-08-25 16:43:04 +02:00
|
|
|
omz update --unattended
|
2020-11-30 12:22:43 +01:00
|
|
|
|
2021-04-14 02:50:38 +02:00
|
|
|
__update_log 'oh-my-zsh extra stuff'
|
2021-03-11 08:41:10 +01:00
|
|
|
__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
|
2018-09-25 10:29:29 +02:00
|
|
|
}
|