mirror of
https://gitlab.com/mlunax/dotfiles.git
synced 2025-04-15 23:16:50 +00:00
169 lines
4.3 KiB
Bash
169 lines
4.3 KiB
Bash
DISABLE_AUTO_UPDATE=true
|
|
|
|
autoload -Uz compinit && compinit
|
|
|
|
iscmd() {
|
|
command -v "$1" > /dev/null
|
|
}
|
|
|
|
export TERM="xterm-256color"
|
|
export OTHER=$HOME/.zsh
|
|
export ZSH=$HOME/.oh-my-zsh
|
|
|
|
__ptrc_prompt() {
|
|
local c_green=$'%{\x1b[32m%}'
|
|
local c_blue=$'%{\x1b[34m%}'
|
|
local c_reset=$'%{\x1b[0m%}'
|
|
local c_red=$'%{\x1b[31m%}'
|
|
local c_cyan=$'%{\x1b[36m%}'
|
|
|
|
if [ "$SSH_TTY" ]; then
|
|
local hostprefix="${c_red}${USER}${c_reset}@${c_cyan}${HOST} "
|
|
else
|
|
local hostprefix=""
|
|
fi
|
|
|
|
echo "${hostprefix}${c_blue}%~ ${c_green}>$c_reset "
|
|
}
|
|
|
|
if iscmd starship; then
|
|
source <(starship init zsh --print-full-init)
|
|
else
|
|
setopt promptsubst
|
|
export PS1='$(__ptrc_prompt)'
|
|
fi
|
|
|
|
if [ -d /usr/share/zsh/plugins ] && [ -d /usr/share/zsh/plugins/zsh-autosuggestions ]; then
|
|
plugins="/usr/share/zsh/plugins"
|
|
else
|
|
plugins="$HOME/.local/share/zsh-plugins"
|
|
fi
|
|
|
|
|
|
## History file configuration
|
|
HISTFILE="$HOME/.zsh_history"
|
|
HISTSIZE=50000000
|
|
SAVEHIST=10000000
|
|
|
|
## History command configuration
|
|
setopt extended_history # record timestamp of command in HISTFILE
|
|
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
|
|
setopt hist_ignore_dups # ignore duplicated commands history list
|
|
setopt hist_ignore_space # ignore commands that start with space
|
|
setopt hist_verify # show command with history expansion to user before running it
|
|
|
|
if iscmd helix; then
|
|
export EDITOR=helix
|
|
elif iscmd nvim; then
|
|
export EDITOR=nvim
|
|
else
|
|
export EDITOR=vim
|
|
fi
|
|
|
|
alias c='docker-compose'
|
|
|
|
if ! iscmd docker-compose; then
|
|
alias c='docker compose'
|
|
fi
|
|
|
|
if ! iscmd docker && iscmd podman; then
|
|
alias docker='podman'
|
|
alias c='podman-compose'
|
|
fi
|
|
|
|
export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket"
|
|
|
|
for f in $OTHER/*.zsh; do
|
|
if [ -f $f ]; then
|
|
source $f
|
|
fi
|
|
done
|
|
|
|
if [ -d "$HOME/.zsh-custom" ]; then
|
|
for f in $HOME/.zsh-custom/*; do
|
|
if [ -f $f ]; then
|
|
source $f
|
|
fi
|
|
done
|
|
fi
|
|
|
|
|
|
# configure completion
|
|
zstyle ':completion:*:*:*:*:*' menu select
|
|
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
|
|
zstyle ':completion:*' special-dirs true
|
|
zstyle ':completion:*' list-colors ''
|
|
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
|
zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm -w -w"
|
|
zstyle ':completion:*' use-cache yes
|
|
zstyle ':completion:*' cache-path "$HOME/.cache/zsh"
|
|
|
|
# https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/key-bindings.zsh
|
|
|
|
# Make sure that the terminal is in application mode when zle is active, since
|
|
# only then values from $terminfo are valid
|
|
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
|
|
zle-line-init() {
|
|
echoti smkx
|
|
}
|
|
zle-line-finish() {
|
|
echoti rmkx
|
|
}
|
|
zle -N zle-line-init
|
|
zle -N zle-line-finish
|
|
fi
|
|
|
|
# Use emacs key bindings
|
|
bindkey -e
|
|
|
|
# Start typing + [Up-Arrow] - fuzzy find history forward
|
|
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
|
autoload -U up-line-or-beginning-search
|
|
zle -N up-line-or-beginning-search
|
|
|
|
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
|
|
fi
|
|
# Start typing + [Down-Arrow] - fuzzy find history backward
|
|
if [[ -n "${terminfo[kcud1]}" ]]; then
|
|
autoload -U down-line-or-beginning-search
|
|
zle -N down-line-or-beginning-search
|
|
|
|
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
|
|
fi
|
|
|
|
# [Home] - Go to beginning of line
|
|
if [[ -n "${terminfo[khome]}" ]]; then
|
|
bindkey "${terminfo[khome]}" beginning-of-line
|
|
fi
|
|
# [End] - Go to end of line
|
|
if [[ -n "${terminfo[kend]}" ]]; then
|
|
bindkey "${terminfo[kend]}" end-of-line
|
|
fi
|
|
|
|
# [Shift-Tab] - move through the completion menu backwards
|
|
if [[ -n "${terminfo[kcbt]}" ]]; then
|
|
bindkey "${terminfo[kcbt]}" reverse-menu-complete
|
|
fi
|
|
|
|
# [Delete] - delete forward
|
|
if [[ -n "${terminfo[kdch1]}" ]]; then
|
|
bindkey "${terminfo[kdch1]}" delete-char
|
|
else
|
|
bindkey "^[[3~" delete-char
|
|
bindkey "^[3;5~" delete-char
|
|
fi
|
|
|
|
# [Ctrl-RightArrow] - move forward one word
|
|
bindkey '^[[1;5C' forward-word
|
|
# [Ctrl-LeftArrow] - move backward one word
|
|
bindkey '^[[1;5D' backward-word
|
|
|
|
# Enable Ctrl-x-e to edit command line
|
|
autoload -U edit-command-line
|
|
zle -N edit-command-line
|
|
bindkey '^xe' edit-command-line
|
|
|
|
DISABLE_MAGIC_FUNCTIONS=true
|
|
source $OTHER/func.zsh
|
|
source "$plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
|
source "$plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|