You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
5.6 KiB
Cheetah

# Pre-requisite: zi (https://github.com/z-shell/zi)
# sh -c "$(curl -fsSL get.zshell.dev)" -- -i skip -b main
typeset -A ZI
ZI[BIN_DIR]="${HOME}/.zi/bin"
source "${ZI[BIN_DIR]}/zi.zsh"
autoload -Uz _zi
(( ${+_comps} )) && _comps[zi]=_zi
# end of zi init
# Vi mode
export KEYTIMEOUT=1
bindkey -v
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:$HOME/.local/bin:$PATH
if [[ -f "$HOME/.zshrc.local" ]]; then
source "$HOME/.zshrc.local"
fi
zi snippet OMZL::history.zsh
zi snippet OMZL::directories.zsh
# apply workaround for refresh: https://github.com/spaceship-prompt/spaceship-prompt/issues/1193
zi light spaceship-prompt/spaceship-prompt
zi light zsh-users/zsh-autosuggestions
zi light zsh-users/zsh-syntax-highlighting
zi is-snippet wait lucid for \
OMZP::{sdk,fzf} \
has'nodenv' \
OMZP::nodenv
export FAVORITE_COMMAND1="{{ .tmux_favorite1 }}"
export FAVORITE_COMMAND2="{{ .tmux_favorite2 }}"
export FAVORITE_COMMAND3="{{ .tmux_favorite3 }}"
export FAVORITE_COMMAND4="{{ .tmux_favorite4 }}"
alias cdd='cd {{ .deploydir }}'
export cdd={{ .deploydir }}
alias rm='rm --interactive --verbose'
alias mv='mv --interactive --verbose'
alias cp='cp --verbose --interactive'
alias dmesg='dmesg -T'
alias grep='grep --color'
# ---------------------------------------------------------------------------
# History
# ---------------------------------------------------------------------------
# Allow multiple sessions to append to one Zsh command history.
setopt APPEND_HISTORY
# Write to the history file immediately, not when the shell exits.
setopt INC_APPEND_HISTORY
# ---------------------------------------------------------------------------
# Git
# ---------------------------------------------------------------------------
if command -v tig &>/dev/null; then
alias tiga='tig --all'
fi
# ---------------------------------------------------------------------------
# Editor
# ---------------------------------------------------------------------------
if hash nvim 2>/dev/null; then
export EDITOR=nvim
elif hash vim 2>/dev/null; then
export EDITOR=vim
elif hash vi 2>/dev/null; then
export EDITOR=vi
else
export EDITOR=nano
fi
export SVN_EDITOR=$EDITOR
export GIT_EDITOR=$EDITOR
export VISUAL=$EDITOR
alias vi=$EDITOR
# ---------------------------------------------------------------------------
# Tmux
# ---------------------------------------------------------------------------
if command -v tmux &>/dev/null; then
alias ta='tmux attach'
alias tkill="for s in \$(tmux list-sessions | awk -F ':' '{print \$1}' | fzf); do
tmux kill-session -t \$s;
done"
fi
# Function to set tmux window title
function set_tmux_title {
if [[ -n "$TMUX" ]]; then
tmux rename-window "$1"
fi
}
# SSH wrapper to change the tmux title locally
function ssh() {
if [[ -n "$TMUX" ]]; then
# Save the original tmux window title
original_title=$(tmux display-message -p '#W')
fi
# Change tmux title before connecting
set_tmux_title "SSH $1"
# Run the actual ssh command with all arguments
command ssh "$@"
# Restore the original tmux window title after disconnecting
if [[ -n "$TMUX" ]]; then
set_tmux_title "$original_title"
tmux set-window-option automatic-rename on
fi
}
export ZSH_TMUX_AUTOSTART=true
export ZSH_TMUX_AUTOSTART_ONCE=false
export ZSH_TMUX_AUTOCONNECT=true
export ZSH_TMUX_DEFAULT_SESSION_NAME=build
export ZSH_TMUX_CONFIG=$HOME/.tmux.conf
zi snippet OMZP::tmux
# ---------------------------------------------------------------------------
# Fzf
# ---------------------------------------------------------------------------
if command -v fzf &>/dev/null; then
change_path_and_find_project() {
cd {{ .projectdir }}
zle fzf-cd-widget
zle reset-prompt
}
zle -N change_path_and_find_project
bindkey '^P' change_path_and_find_project
fi
# ---------------------------------------------------------------------------
# Sdkman
# ---------------------------------------------------------------------------
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
# ---------------------------------------------------------------------------
# Maven
# ---------------------------------------------------------------------------
if command -v mvn &>/dev/null; then
if [ -f "{{ .java_truststore_file }}" ]; then
alias m='mvn -Djavax.net.ssl.trustStore={{ .java_truststore_file }} -Djavax.net.ssl.trustStorePassword={{ .java_truststore_password }}'
else
alias m='mvn'
fi
alias mvnp='m -Dmaven.test.skip -Dmaven.javadoc.skip=true -DskipMunitTests clean package'
alias mvnd='m -Dmaven.test.skip -Dmaven.javadoc.skip=true deploy -P profile-nexus'
alias mvni='m -Dmaven.test.skip -Dmaven.javadoc.skip=true clean install'
function mbump() {
if [ $# -eq 0 ]; then
echo "Usage: mbump <version> (means -SNAPSHOT) or mbump <version> <kind> (kind is R or S)"
else
if [ $# -gt 1 ] && [ "$2" = "R" ]; then
kind="RELEASE"
else
kind="SNAPSHOT"
fi
mvn versions:set -DgenerateBackupPoms=false -DnewVersion="$1-$kind"
fi
}
# copy maven artifact
alias d="python3 ~/.local/bin/deploy.py '$cdd'"
fi
# ---------------------------------------------------------------------------
# Nix
# ---------------------------------------------------------------------------
if command nix-env &>/dev/null; then
alias nix-update='nix-channel --update && nix-env -u'
nix-search() {
nix-env -qa --description ".*$1.*"
}
fi