143 lines
3.8 KiB
Plaintext
143 lines
3.8 KiB
Plaintext
export PATH="$PATH:$HOME/.local/bin:$HOME/bin"
|
|
export LANG=en_US.UTF-8
|
|
export LC_CTYPE=en_US.UTF-8
|
|
export LC_COLLATE=C
|
|
|
|
export EDITOR=nvim
|
|
|
|
# eval "$(dircolors)"; echo "$LS_COLORS"
|
|
export LS_COLORS='rs=0:di=01;34:ln=01;33:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32'
|
|
|
|
HISTFILE=$HOME/.zsh_history
|
|
HISTSIZE=10000
|
|
SAVEHIST=10000
|
|
|
|
setopt auto_cd interactive_comments prompt_subst share_history
|
|
setopt append_history hist_ignore_dups hist_ignore_all_dups hist_reduce_blanks
|
|
|
|
fpath=(~/.zsh/completions $fpath)
|
|
|
|
autoload -Uz compinit
|
|
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case-insensitive
|
|
zstyle ':completion:*' use-cache on
|
|
zstyle ':completion:*' cache-path ~/.zsh/cache
|
|
compinit
|
|
|
|
git_prompt_info() {
|
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
local branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD)
|
|
echo " %F{green}($branch)%f"
|
|
fi
|
|
}
|
|
abbrev_path() {
|
|
local pwd="${PWD/#$HOME/~}"
|
|
local parts=("${(@s:/:)pwd}")
|
|
local len=${#parts}
|
|
|
|
if (( len <= 1 )); then
|
|
echo "$pwd"
|
|
return
|
|
fi
|
|
|
|
local result=""
|
|
for (( i=1; i<len; i++ )); do
|
|
result+="${parts[i]:0:1}/"
|
|
done
|
|
result+="${parts[len]}"
|
|
echo "$result"
|
|
}
|
|
|
|
PROMPT='%n@%m%f %F{blue}$(abbrev_path)%f$(git_prompt_info) $ '
|
|
# PROMPT='%n@%m%f %F{blue}%~%f$(git_prompt_info) $ '
|
|
|
|
autoload -U up-line-or-beginning-search down-line-or-beginning-search
|
|
zle -N up-line-or-beginning-search
|
|
zle -N down-line-or-beginning-search
|
|
bindkey '^[[A' up-line-or-beginning-search
|
|
bindkey '^[OA' up-line-or-beginning-search
|
|
bindkey '^[[B' down-line-or-beginning-search
|
|
bindkey '^[OB' down-line-or-beginning-search
|
|
bindkey '^U' backward-kill-line
|
|
|
|
if command -v nvim >/dev/null 2>&1; then
|
|
alias vim='nvim'
|
|
fi
|
|
|
|
case "$OSTYPE" in
|
|
linux*) alias ls='ls --color=auto --group-directories-first' ;;
|
|
darwin*) alias ls='ls --color=auto' ;;
|
|
esac
|
|
|
|
h() {
|
|
history 0 | grep -iE --color=always "$@" | tail -20
|
|
}
|
|
|
|
alias ll='ls -lF'
|
|
alias lla='ll -a'
|
|
alias ld='ls -ld */'
|
|
|
|
alias ga='git add'
|
|
alias gcm='git commit -m'
|
|
alias gp='git push'
|
|
alias gst='git status'
|
|
# alias gd='git diff --patience --color-moved=dimmed-zebra --word-diff=plain --function-context --ignore-space-change -U3'
|
|
alias gd='git diff --patience --color-moved=dimmed-zebra --ignore-space-change -U5'
|
|
alias glg='git log --oneline --graph --decorate --all'
|
|
|
|
alias k='kubectl'
|
|
|
|
# opencode
|
|
export PATH="$HOME/.opencode/bin:$PATH"
|
|
|
|
git-safe-delete() {
|
|
local branch="$1"
|
|
local base="${2:-main}"
|
|
|
|
if [[ -z "$branch" ]]; then
|
|
echo "Usage: git-safe-delete <branch> [base]"
|
|
return 1
|
|
fi
|
|
|
|
if [[ "$branch" == "$(git branch --show-current)" ]]; then
|
|
echo "Cannot delete current branch."
|
|
return 1
|
|
fi
|
|
|
|
git fetch origin >/dev/null 2>&1
|
|
|
|
if git diff --quiet "$base..$branch"; then
|
|
echo "No content differences with $base."
|
|
git branch -D "$branch"
|
|
echo "Deleted $branch"
|
|
else
|
|
echo "Branch differs from $base."
|
|
echo "Diff summary:"
|
|
git diff --stat "$base..$branch"
|
|
echo
|
|
read "confirm?Force delete anyway? (y/N): "
|
|
[[ "$confirm" == "y" ]] && git branch -D "$branch"
|
|
fi
|
|
}
|
|
|
|
_git_safe_delete() {
|
|
_arguments \
|
|
'1:local branch:($(git for-each-ref --format="%(refname:short)" refs/heads))' \
|
|
'2:base branch (optional):($(git for-each-ref --format="%(refname:short)" refs/heads))'
|
|
}
|
|
|
|
compdef _git_safe_delete git-safe-delete
|
|
|
|
|
|
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
|
|
|
# pnpm
|
|
export PNPM_HOME="/home/tomas/.local/share/pnpm"
|
|
case ":$PATH:" in
|
|
*":$PNPM_HOME:"*) ;;
|
|
*) export PATH="$PNPM_HOME:$PATH" ;;
|
|
esac
|
|
# pnpm end
|