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"
|
2022-12-26 21:12:33 +01:00
|
|
|
|
|
|
|
# If running in a TTY, start sway
|
|
|
|
[[ $(tty) = /dev/tty1 ]] && exec $HOME/.config/sway/run.sh
|
|
|
|
|
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
|
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
|
2022-12-11 21:21:32 +01:00
|
|
|
SPACESHIP_HOST_SHOW_FULL=true
|
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-12-16 17:42:51 +01:00
|
|
|
export EDITOR=nvim
|
2020-11-13 19:31:56 +01:00
|
|
|
export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig:$HOME/.local/share/pkgconfig:/usr/local/lib/pkgconfig"
|
2019-02-11 10:30:22 +01:00
|
|
|
export GPG_TTY=$(tty)
|
2021-09-18 17:18:01 +02:00
|
|
|
export VAGRANT_DEFAULT_PROVIDER=libvirt
|
|
|
|
|
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
|
|
|
|
|
2022-12-15 11:52:00 +01:00
|
|
|
if [ -s $HOME/.zshrc_secret ]; then
|
|
|
|
[ $(stat -c '%a' $HOME/.zshrc_secret) != 600 ] && \
|
|
|
|
printf "\e[91m~/.zshrc_secret is readable by other users, fix permissions!\e[0m\n"
|
|
|
|
source $HOME/.zshrc_secret
|
|
|
|
fi
|
|
|
|
|
2018-09-25 10:29:29 +02:00
|
|
|
# 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
|
2022-12-16 17:42:51 +01:00
|
|
|
export GIT_EDITOR=$EDITOR
|
2021-08-25 16:48:03 +02:00
|
|
|
alias gc='git commit --verbose --signoff'
|
|
|
|
alias gcan!='git commit --verbose --signoff --amend --date now --reset-author'
|
2022-12-15 11:53:39 +01:00
|
|
|
alias gfp='git format-patch'
|
|
|
|
alias gsm='git send-email'
|
|
|
|
alias gsmc='git send-email --compose'
|
2021-08-25 16:48:03 +02:00
|
|
|
|
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'
|
|
|
|
|
2022-12-16 17:43:18 +01:00
|
|
|
# neovim
|
|
|
|
alias n='nvim'
|
|
|
|
|
2022-09-08 11:16:02 +02:00
|
|
|
# ripgrep
|
|
|
|
alias rg='rg --no-heading'
|
|
|
|
|
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'
|
2023-02-04 17:03:04 +01:00
|
|
|
alias ip='ip --color'
|
2022-08-12 14:57:29 +02:00
|
|
|
alias journalctl-clean='journalctl --vacuum-time=7d'
|
2022-10-10 21:11:48 +02:00
|
|
|
alias nocorrect=''
|
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'
|
2022-09-08 11:16:31 +02:00
|
|
|
alias yt-dlp-mp3="yt-dlp -o '%(title)s.%(ext)s' -i -x --audio-quality 320K --audio-format mp3"
|
|
|
|
alias yt-dlp-video="yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4"
|
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
|
|
|
|
}
|
|
|
|
|
2022-12-15 11:54:20 +01:00
|
|
|
curl-time() {
|
|
|
|
curl -w @- -o /dev/null -s "$@" <<'EOF'
|
|
|
|
time_namelookup: %{time_namelookup}\n
|
|
|
|
time_connect: %{time_connect}\n
|
|
|
|
time_appconnect: %{time_appconnect}\n
|
|
|
|
time_pretransfer: %{time_pretransfer}\n
|
|
|
|
time_redirect: %{time_redirect}\n
|
|
|
|
time_starttransfer: %{time_starttransfer}\n
|
|
|
|
----------\n
|
|
|
|
time_total: %{time_total}\n
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
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
|
2022-12-22 13:17:07 +01:00
|
|
|
elif [ -f /etc/debian_version ]; then
|
2022-12-15 12:01:07 +01:00
|
|
|
sudo apt update
|
|
|
|
sudo apt full-upgrade --assume-yes
|
2021-09-18 17:18:01 +02:00
|
|
|
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 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"
|
|
|
|
|
|
|
|
unsetopt pushdsilent
|
2018-09-25 10:29:29 +02:00
|
|
|
}
|