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.

171 lines
5.2 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
# 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
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
4 weeks ago
export FAVORITE_COMMAND1="{{ .tmux_favorite1 }}"
export FAVORITE_COMMAND2="{{ .tmux_favorite2 }}"
export FAVORITE_COMMAND3="{{ .tmux_favorite3 }}"
export FAVORITE_COMMAND4="{{ .tmux_favorite4 }}"
4 weeks ago
alias cdd='cd {{ .deploydir }}'
export cdd={{ .deploydir }}
4 weeks ago
# ---------------------------------------------------------------------------
# History
# ---------------------------------------------------------------------------
# Allow multiple sessions to append to one Zsh command history.
4 weeks ago
setopt APPEND_HISTORY
# Write to the history file immediately, not when the shell exits.
4 weeks ago
setopt INC_APPEND_HISTORY
# ---------------------------------------------------------------------------
# Git
# ---------------------------------------------------------------------------
4 weeks ago
if command -v tig &>/dev/null; then
alias tiga='tig --all'
fi
4 weeks ago
# ---------------------------------------------------------------------------
4 weeks ago
# Editor
4 weeks ago
# ---------------------------------------------------------------------------
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
4 weeks ago
4 weeks ago
# ---------------------------------------------------------------------------
4 weeks ago
# Tmux
4 weeks ago
# ---------------------------------------------------------------------------
# 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
4 weeks ago
# ---------------------------------------------------------------------------
4 weeks ago
# Fzf
4 weeks ago
# ---------------------------------------------------------------------------
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
4 weeks ago
# ---------------------------------------------------------------------------
4 weeks ago
# Sdkman
4 weeks ago
# ---------------------------------------------------------------------------
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
4 weeks ago
# ---------------------------------------------------------------------------
4 weeks ago
# Maven
4 weeks ago
# ---------------------------------------------------------------------------
4 weeks ago
if command -v mvn &>/dev/null; then
4 weeks ago
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