# 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 zi snippet OMZL::history.zsh 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 # If you come from bash you might have to change your $PATH. export PATH=$HOME/bin:$HOME/.local/bin:$PATH # --------------------------------------------------------------------------- # USER CONFIGURATION # --------------------------------------------------------------------------- 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 }} if [[ -f "$HOME/.zshrc.local" ]]; then source "$HOME/.zshrc.local" fi # --------------------------------------------------------------------------- # 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 # --------------------------------------------------------------------------- # 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=true 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 __fzf_cd__ () { local cmd dir cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune -o -type d -print 2> /dev/null | cut -b3-"}" dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m) && printf 'cd %q' "$dir" } # quickly find a project p(){ cd {{ .projectdir }} && `__fzf_cd__` && [[ -d ".git" ]] && git fetch } 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 (means -SNAPSHOT) or mbump (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