2021-01-28 13:18:23 +00:00
|
|
|
GITSTATUS_LOG_LEVEL=DEBUG
|
2020-06-03 10:27:29 +00:00
|
|
|
# Commands
|
2020-10-14 12:48:03 +00:00
|
|
|
if test "$PWD" = "$HOME" && test "$0" != "$SHELL"; then
|
2022-04-06 08:30:51 +00:00
|
|
|
neofetch --config $XDG_CONFIG_HOME/neofetch/config-$(test -z "$DISPLAY" && test "$XDG_VTNR" -eq 1 && echo short || echo server).conf
|
2020-06-08 09:41:03 +00:00
|
|
|
timew | head -3
|
2020-10-14 12:48:03 +00:00
|
|
|
fi 2>/dev/null || return 0
|
2020-06-03 10:27:29 +00:00
|
|
|
|
2020-03-31 20:32:08 +00:00
|
|
|
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
|
2020-03-23 19:46:08 +00:00
|
|
|
# Initialization code that may require console input (password prompts, [y/n]
|
|
|
|
# confirmations, etc.) must go above this block; everything else may go below.
|
2022-09-15 17:21:16 +00:00
|
|
|
#if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
|
|
|
# source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
|
|
|
#fi
|
2020-03-23 19:46:08 +00:00
|
|
|
|
2020-03-08 18:58:52 +00:00
|
|
|
DEFAULT_USER=$USER
|
|
|
|
|
2020-03-23 19:46:08 +00:00
|
|
|
ZSH_THEME="powerlevel10k/powerlevel10k"
|
2020-06-03 10:27:29 +00:00
|
|
|
#POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator context dir rbenv vcs) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs time)
|
|
|
|
#ZSH_CUSTOM=$ZSH/custom
|
2020-03-08 18:58:52 +00:00
|
|
|
|
2020-06-03 10:27:29 +00:00
|
|
|
HIST_STAMPS="yyyy-mm-dd" # history command timestamps
|
2020-03-08 18:58:52 +00:00
|
|
|
|
2020-06-03 10:27:29 +00:00
|
|
|
# COMPLETION
|
|
|
|
# ENABLE_CORRECTION="true" # Correct command arguments
|
|
|
|
HYPHEN_INSENSITIVE="true" # - and _ interchangeable
|
|
|
|
COMPLETION_WAITING_DOTS="true" # Dots while waiting for completion
|
|
|
|
DISABLE_UNTRACKED_FILES_DIRTY="true" # DOn't mark untracked files as dirty - speeds up status check
|
2020-03-08 18:58:52 +00:00
|
|
|
|
|
|
|
|
2020-06-03 10:27:29 +00:00
|
|
|
# Plugins can be found in $ZSH/plugins/
|
|
|
|
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
|
2020-03-08 18:58:52 +00:00
|
|
|
plugins=(
|
2020-10-07 19:46:34 +00:00
|
|
|
#git
|
|
|
|
gitfast
|
2020-10-13 09:19:09 +00:00
|
|
|
#git-auto-fetch
|
2020-06-03 10:27:29 +00:00
|
|
|
zsh-autosuggestions
|
2021-07-17 20:48:33 +00:00
|
|
|
fast-syntax-highlighting
|
2020-06-08 09:41:03 +00:00
|
|
|
zsh-vim-mode
|
2020-10-13 09:16:07 +00:00
|
|
|
history-substring-search
|
2020-03-08 18:58:52 +00:00
|
|
|
)
|
|
|
|
|
2020-06-03 10:27:29 +00:00
|
|
|
_comp_options+=(globdots) # Show files starting with dot in autocomplete
|
2021-04-19 08:38:28 +00:00
|
|
|
fpath=($fpath "$CONFIG_ZSH/completion") # Custom completions
|
2020-06-26 21:27:38 +00:00
|
|
|
ZSH_COMPDUMP="$XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION" # Cache completions
|
|
|
|
DISABLE_UPDATE_PROMPT=true
|
2021-03-03 13:43:16 +00:00
|
|
|
ZSH_DISABLE_COMPFIX=true
|
2020-03-08 18:58:52 +00:00
|
|
|
|
2022-11-29 22:32:54 +00:00
|
|
|
# For fresh systems
|
|
|
|
test -d "$ZSH" || source $HOME/.zshenv
|
2020-03-08 18:58:52 +00:00
|
|
|
source $ZSH/oh-my-zsh.sh
|
|
|
|
|
|
|
|
## Functions
|
|
|
|
|
|
|
|
tab_list_files() {
|
|
|
|
if [[ $#BUFFER == 0 ]]; then
|
|
|
|
BUFFER="ls "
|
|
|
|
CURSOR=3
|
|
|
|
zle list-choices
|
|
|
|
zle backward-kill-word
|
|
|
|
elif [[ $BUFFER =~ ^[[:space:]][[:space:]].*$ ]]; then
|
|
|
|
BUFFER="./"
|
|
|
|
CURSOR=2
|
|
|
|
zle list-choices
|
|
|
|
[ -z ${TAB_LIST_FILES_PREFIX+x} ] && BUFFER=" " CURSOR=2
|
|
|
|
elif [[ $BUFFER =~ ^[[:space:]]*$ ]]; then
|
|
|
|
BUFFER="cd "
|
|
|
|
CURSOR=3
|
|
|
|
zle list-choices
|
|
|
|
[ -z ${TAB_LIST_FILES_PREFIX+x} ] && BUFFER=" " CURSOR=1
|
|
|
|
else
|
|
|
|
BUFFER_=$BUFFER
|
|
|
|
CURSOR_=$CURSOR
|
|
|
|
zle expand-or-complete || zle expand-or-complete || {
|
|
|
|
BUFFER="ls "
|
|
|
|
CURSOR=3
|
|
|
|
zle list-choices
|
|
|
|
BUFFER=$BUFFER_
|
|
|
|
CURSOR=$CURSOR_
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
zle -N tab_list_files
|
|
|
|
bindkey '^I' tab_list_files
|
|
|
|
|
|
|
|
fancy-ctrl-z() {
|
|
|
|
if [[ $#BUFFER -eq 0 ]]; then
|
|
|
|
bg
|
|
|
|
zle redisplay
|
|
|
|
else
|
|
|
|
zle push-input
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
zle -N fancy-ctrl-z
|
|
|
|
bindkey '^z' fancy-ctrl-z
|
|
|
|
bindkey '^q' push-line-or-edit
|
|
|
|
|
|
|
|
export KEYTIMEOUT=1
|
|
|
|
|
2022-12-13 12:07:02 +00:00
|
|
|
# Obsolete because of zsh-vim-mode plugin - Custom VIM bindings {{{
|
2020-06-03 10:27:29 +00:00
|
|
|
#bindkey -v
|
2020-03-08 18:58:52 +00:00
|
|
|
#autoload -Uz history-search-end
|
|
|
|
#
|
|
|
|
#zle -N history-beginning-search-backward-end history-search-end
|
|
|
|
#zle -N history-beginning-search-forward-end history-search-end
|
|
|
|
#
|
|
|
|
#bindkey -M vicmd '^[[A' history-beginning-search-backward-end \
|
|
|
|
# '^[OA' history-beginning-search-backward-end \
|
|
|
|
# '^[[B' history-beginning-search-forward-end \
|
|
|
|
# '^[OB' history-beginning-search-forward-end
|
|
|
|
#bindkey -M viins '^[[A' history-beginning-search-backward-end \
|
|
|
|
# '^[OA' history-beginning-search-backward-end \
|
|
|
|
# '^[[B' history-beginning-search-forward-end \
|
|
|
|
# '^[OB' history-beginning-search-forward-end
|
2020-06-03 10:27:29 +00:00
|
|
|
# }}}
|
2020-03-08 18:58:52 +00:00
|
|
|
|
2020-06-08 09:41:03 +00:00
|
|
|
# Obsolete: powerlevel10k - Show time on the right after executing command {{{
|
2020-03-08 18:58:52 +00:00
|
|
|
# strlen() {
|
|
|
|
# FOO=$1
|
|
|
|
# local zero='%([BSUbfksu]|([FB]|){*})'
|
|
|
|
# LEN=${#${(S%%)FOO//$~zero/}}
|
|
|
|
# echo $LEN
|
|
|
|
# }
|
|
|
|
# preexec() {
|
|
|
|
# DATE=$( date +"[%H:%M:%S]" )
|
|
|
|
# local len_right=$( strlen "$DATE" )
|
|
|
|
# len_right=$(( $len_right+1 ))
|
|
|
|
# local right_start=$(($COLUMNS - $len_right))
|
|
|
|
#
|
|
|
|
# local len_cmd=$( strlen "$@" )
|
|
|
|
# local len_prompt=$(strlen "$PROMPT" )
|
|
|
|
# local len_left=$(($len_cmd+$len_prompt))
|
|
|
|
#
|
|
|
|
# RDATE="\033[${right_start}C ${DATE}"
|
|
|
|
#
|
|
|
|
# if [ $len_left -lt $right_start ]; then
|
|
|
|
# # command does not overwrite right prompt - ok to move up one line
|
|
|
|
# echo -e "\033[1A${RDATE}"
|
|
|
|
# else
|
|
|
|
# echo -e "${RDATE}"
|
|
|
|
# fi
|
|
|
|
# }
|
2020-06-03 10:27:29 +00:00
|
|
|
# }}}
|
2020-03-08 18:58:52 +00:00
|
|
|
|
|
|
|
## User configuration
|
|
|
|
|
|
|
|
# turn on spelling correction
|
|
|
|
setopt correct
|
2021-12-14 18:46:28 +00:00
|
|
|
CORRECT_IGNORE="[_|.]*"
|
2021-12-02 09:43:35 +00:00
|
|
|
# command history - https://unix.stackexchange.com/a/273863
|
2022-05-19 20:24:44 +00:00
|
|
|
# TODO always much shorter
|
2021-12-02 09:43:35 +00:00
|
|
|
HISTSIZE=100000
|
|
|
|
SAVEHIST=$HISTSIZE
|
|
|
|
setopt inc_append_history
|
|
|
|
setopt share_history
|
|
|
|
setopt hist_expire_dups_first
|
|
|
|
setopt hist_ignore_dups
|
|
|
|
setopt hist_find_no_dups
|
|
|
|
setopt hist_save_no_dups
|
|
|
|
setopt hist_reduce_blanks
|
|
|
|
unsetopt hist_ignore_space
|
2023-03-14 22:33:06 +00:00
|
|
|
zshaddhistory() {
|
|
|
|
[[ $1 != netkeeper* ]] && [[ $1 != killm* ]]
|
|
|
|
}
|
2021-12-02 09:43:35 +00:00
|
|
|
|
2022-11-29 22:32:54 +00:00
|
|
|
setopt sh_word_split
|
2021-12-02 09:43:35 +00:00
|
|
|
setopt extended_glob
|
|
|
|
unsetopt case_glob
|
2020-06-03 10:27:29 +00:00
|
|
|
|
2020-06-08 09:41:03 +00:00
|
|
|
setopt pipefail
|
|
|
|
|
2021-12-14 19:31:06 +00:00
|
|
|
# Empower zmv (see ZSHCONTRIB(1))
|
2021-10-13 18:02:37 +00:00
|
|
|
alias szmv='sudo zsh -c autoload zmv && zmv'
|
2020-03-08 18:58:52 +00:00
|
|
|
autoload zmv
|
|
|
|
alias zmv='noglob zmv'
|
2021-02-15 19:57:17 +00:00
|
|
|
alias zmw='noglob zmv -W'
|
2020-03-08 18:58:52 +00:00
|
|
|
alias zcp='noglob zmv -C'
|
|
|
|
alias zln='noglob zmv -L'
|
|
|
|
alias zsy='noglob zmv -Ls'
|
|
|
|
|
2021-12-14 19:31:06 +00:00
|
|
|
for file in $CONFIG_SHELLS/*
|
|
|
|
do source $file
|
|
|
|
done
|
2020-11-22 18:55:59 +00:00
|
|
|
|
|
|
|
# GENERATED SHIT
|
2020-03-08 18:58:52 +00:00
|
|
|
|
2021-12-14 18:46:28 +00:00
|
|
|
source_existing() {
|
|
|
|
for arg
|
|
|
|
do test -s "$arg" && source "$arg"
|
|
|
|
done
|
|
|
|
}
|
2021-12-14 19:31:06 +00:00
|
|
|
|
2021-12-14 18:46:28 +00:00
|
|
|
source_existing $CONFIG_ZSH/.p10k.zsh # To customize prompt, run `p10k configure` or edit .p10k.zsh.
|
|
|
|
source_existing /usr/share/fzf/key-bindings.zsh /usr/share/fzf/completion.zsh
|
2020-03-23 19:46:08 +00:00
|
|
|
|
2021-12-14 18:46:28 +00:00
|
|
|
source_existing "$NVM_DIR/nvm.sh"
|
|
|
|
source_existing "$NVM_DIR/bash_completion"
|
2020-06-03 10:27:29 +00:00
|
|
|
|
2021-12-14 18:46:28 +00:00
|
|
|
source_existing $XDG_CONFIG_HOME/broot/launcher/bash/br
|
2020-11-14 01:28:26 +00:00
|
|
|
|
2021-12-14 18:46:28 +00:00
|
|
|
which zoxide >/dev/null &&
|
2021-12-14 19:31:06 +00:00
|
|
|
eval "$(zoxide init zsh)"
|
2021-07-02 16:32:09 +00:00
|
|
|
|
2022-11-29 22:32:54 +00:00
|
|
|
source_existing $HOME/.nix-profile/etc/profile.d/nix.sh
|
2020-11-14 01:28:26 +00:00
|
|
|
which direnv >/dev/null && eval "$(direnv hook zsh)"
|
|
|
|
|
2021-02-16 12:08:56 +00:00
|
|
|
true
|