Archived
1
0
Fork 0
This repository has been archived on 2024-06-19. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/files/.zshrc

178 lines
3.5 KiB
Bash

#
# ~/.zshrc
#
# If not running interactively, do nothing
[[ $- != *i* ]] && return
PATH_ARRAY=(
"/var/lib/snapd/snap/bin"
"$HOME/.poetry/bin"
"$HOME/.yarn/bin"
"$HOME/.cargo/bin"
"$HOME/local/bin"
)
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=(
cargo
colored-man-pages
docker
docker-compose
git
git-extras
kubectl
sudo
z
# must be last
zsh-syntax-highlighting
)
if [ "$(uname)" = "Darwin" ]; then
plugins=(osx "${plugins[@]}")
fi
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
export MANPATH="/usr/local/man:$MANPATH"
export LANG=en_US.UTF-8
export LC_ALL=$LANG
export HISTCONTROL=ignoreboth
export HISTSIZE=10000
export HISTFILESIZE=$HISTSIZE
export EDITOR=nvim
export GIT_EDITOR=$EDITOR
export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig:$HOME/local/lib64/pkgconfig:$HOME/local/share/pkgconfig
export GEM_HOME=$HOME/.gem
PATH_ARRAY+="$GEM_HOME/ruby/$(ruby --version | cut -c 6-8).0/bin"
# Golang
export GOPATH=$HOME/.go
PATH_ARRAY+=$GOPATH/bin
export GPG_TTY=$(tty)
export WINEARCH=win32
export DEVKITPRO=/opt/devkitpro
export DEVKITARM=${DEVKITPRO}/devkitARM
export DEVKITPPC=${DEVKITPRO}/devkitPPC
PATH_ARRAY+="${DEVKITPRO}/tools/bin"
PATH_ARRAY+="${DEVKITPPC}/bin"
PATH_ARRAY+="${DEVKITARM}/bin"
export PATH="${(j[:])PATH_ARRAY}:$PATH"
# Setup base16 themes
export BASE16_SHELL=$HOME/.config/base16-shell
[ -n "$PS1" ] && [ -s $BASE16_SHELL/profile_helper.sh ] && eval "$($BASE16_SHELL/profile_helper.sh)"
# 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
alias sudo='sudo '
alias yt-dl="youtube-dl -o '%(title)s.%(ext)s' -i -x --audio-quality 320K --audio-format mp3"
alias weather='curl wttr.in'
alias diff='diff -u --color=always'
alias gcan!='git commit --amend --date now --reset-author'
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"
}
source $HOME/.zsh_platform
__update_log() {
printf "\n 📦 \e[92mUpdating $1\e[0m\n"
}
update_omz_custom() {
setopt pushdsilent
pushd $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
git pull
popd
pushd $ZSH_CUSTOM/themes/spaceship-prompt
git pull
popd
unsetopt pushdsilent
}
update() {
__update_log 'system packages'
update_platform
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 custom stuff'
update_omz_custom
}