160 lines
4.3 KiB
Bash
160 lines
4.3 KiB
Bash
# Basic
|
|
export LANG=en_US.UTF-8
|
|
export EDITOR=vim
|
|
export HISTFILE=~/.zhistory
|
|
export HISTSIZE=100000
|
|
export SAVEHIST=100000
|
|
|
|
# History behavior
|
|
setopt INC_APPEND_HISTORY SHARE_HISTORY
|
|
setopt HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS
|
|
setopt HIST_VERIFY
|
|
|
|
# General quality-of-life
|
|
setopt EXTENDED_GLOB
|
|
setopt INTERACTIVE_COMMENTS
|
|
setopt MULTIOS # pipe to multiple outputs
|
|
setopt AUTO_PUSHD # cd becomes pushd
|
|
setopt AUTO_NAME_DIRS # use named dirs when possible
|
|
setopt GLOB_COMPLETE # expand globs
|
|
setopt ZLE
|
|
setopt NO_FLOW_CONTROL # disable Ctrl-S
|
|
setopt CLOBBER # allow > to overwrite
|
|
setopt NO_CASE_GLOB # case insensitive globbing
|
|
setopt NUMERIC_GLOB_SORT
|
|
setopt RC_EXPAND_PARAM # better array expansion
|
|
|
|
unsetopt AUTO_CD # don't run directories as commands
|
|
unsetopt CORRECT # no "did you mean?"
|
|
unsetopt BANG_HIST # no ! history expansion
|
|
|
|
# modules
|
|
zmodload zsh/datetime
|
|
zmodload zsh/mathfunc
|
|
|
|
# plugin manager
|
|
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}}/.zinit.git"
|
|
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
|
|
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
|
|
source "${ZINIT_HOME}/zinit.zsh"
|
|
|
|
zinit light zsh-users/zsh-autosuggestions
|
|
zinit light zsh-users/zsh-syntax-highlighting
|
|
zinit light zsh-users/zsh-completions
|
|
|
|
# completions
|
|
autoload -Uz compinit
|
|
compinit
|
|
|
|
# idk?
|
|
zstyle ':completion:*' menu select
|
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
|
|
bindkey '^[[Z' reverse-menu-complete # shift-tab
|
|
|
|
# search from prefix
|
|
zinit light zsh-users/zsh-history-substring-search
|
|
bindkey "${key[Up]}" history-substring-search-up
|
|
bindkey "${key[Down]}" history-substring-search-down
|
|
|
|
# keybindings
|
|
bindkey -e # emacs mode
|
|
bindkey '\e[1~' beginning-of-line
|
|
bindkey '\e[4~' end-of-line
|
|
bindkey "\eOH" beginning-of-line
|
|
bindkey "\eOF" end-of-line
|
|
bindkey '^[[3~' delete-char # Delete key
|
|
bindkey '^[[1;5C' forward-word # Ctrl+Right
|
|
bindkey '^[[1;5D' backward-word # Ctrl+Left
|
|
bindkey '^[.' insert-last-word # Alt+. or Esc,. (last arg of prev cmd)
|
|
bindkey '^[b' backward-word # Alt+B
|
|
bindkey '^[f' forward-word # Alt+F
|
|
bindkey '^[^?' backward-kill-word # Alt+Backspace
|
|
bindkey '^Q' push-line # Ctrl+Q (stash line, type another, comes back)
|
|
autoload -Uz edit-command-line && zle -N edit-command-line
|
|
bindkey '^X^E' edit-command-line # Ctrl+X,E → edit in $EDITOR
|
|
|
|
# starship config (inline)
|
|
export STARSHIP_CONFIG=~/.config/starship.toml
|
|
mkdir -p ~/.config
|
|
cat > $STARSHIP_CONFIG << 'EOF'
|
|
add_newline = true
|
|
format = """$git_branch$git_status$character"""
|
|
right_format = """$username[@](red)$hostname $cmd_duration$time $directory"""
|
|
|
|
[git_branch]
|
|
format = "[$branch]($style) "
|
|
|
|
[git_status]
|
|
format = '[$all_status$ahead_behind]($style)'
|
|
|
|
[username]
|
|
show_always = true
|
|
format = "[$user]($style)"
|
|
style_user = "blue bold"
|
|
|
|
[hostname]
|
|
ssh_only = false
|
|
format = "[$hostname]($style)"
|
|
style = "blue bold"
|
|
|
|
[directory]
|
|
truncation_length = 5
|
|
truncate_to_repo = false
|
|
style = "cyan bold"
|
|
|
|
[cmd_duration]
|
|
min_time = 5_000
|
|
show_milliseconds = true
|
|
format = '[$duration]($style) '
|
|
|
|
[time]
|
|
disabled = false
|
|
format = "[$time]($style)"
|
|
style = "green"
|
|
|
|
[character]
|
|
success_symbol = "[➤](green)"
|
|
error_symbol = "[➤](red)"
|
|
EOF
|
|
|
|
# starship prompt
|
|
zinit ice as"command" from"gh-r" \
|
|
atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \
|
|
atpull"%atclone" src"init.zsh"
|
|
zinit light starship/starship
|
|
|
|
# paths
|
|
typeset -U path
|
|
path=(
|
|
$HOME/.local/bin
|
|
$HOME/.cargo/bin
|
|
$path
|
|
)
|
|
|
|
# aliases: git
|
|
alias g="git"
|
|
alias a="git add --all :/"
|
|
alias b="git branch"
|
|
alias c="git commit -am"
|
|
alias ch="git checkout"
|
|
alias pull="git pull"
|
|
alias rb="git reset HEAD --hard"
|
|
alias s="git status"
|
|
alias st="git stash"
|
|
alias dc="a && c 'wip'"
|
|
|
|
# aliases: dotfiles (bare repo)
|
|
alias .g='git --git-dir=$HOME/.dotgit/ --work-tree=$HOME'
|
|
alias .gs='.g status -uno'
|
|
alias .gp='.g commit -am "auto" && .g push'
|
|
|
|
# aliases: tmux
|
|
alias tmuxr="tmux new-session -A -s auto"
|
|
alias tmuxn="tmux new-session -A -s auto \; new-window"
|
|
alias tmuxa="tmux new-session -A -s"
|
|
|
|
# aliases: misc
|
|
alias zshreload="exec zsh"
|
|
alias -g LATEST='*(om[1])' # glob: most recently modified
|
|
alias FUNCTION_PRELUDE="setopt LOCAL_OPTIONS PIPE_FAIL XTRACE ERR_RETURN"
|