mirror of
https://github.com/materusPL/nixos-config
synced 2026-06-24 17:36:41 +00:00
common: zsh changes
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
__HOME_ZSHRC_SOURCED=1
|
||||
|
||||
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
|
||||
|
||||
bindkey -e
|
||||
if [ -n "$EAT_SHELL_INTEGRATION_DIR" ]; then
|
||||
source "$EAT_SHELL_INTEGRATION_DIR/zsh";
|
||||
fi
|
||||
|
||||
ZSH_DATA_DIR="${XDG_CONFIG_HOME:-"$HOME/.config"}/zsh/data"
|
||||
ZSH_CONFIG_DIR="${XDG_CONFIG_HOME:-"$HOME/.config"}/zsh/cfg"
|
||||
|
||||
#Check if terminal is fullcolor
|
||||
if zmodload zsh/terminfo && (( "$terminfo[colors]" >= "256" )); then
|
||||
__MATERUS_ZSH_256COLORS="${__MATERUS_ZSH_256COLORS:-1}"; else
|
||||
__MATERUS_ZSH_256COLORS="${__MATERUS_ZSH_256COLORS:-0}";
|
||||
fi
|
||||
|
||||
#MSYS
|
||||
if [[ "$(uname -s)" =~ ^MSYS_NT.* ]]; then
|
||||
#Use windows symlink instead copy
|
||||
MSYS=winsymlinks:nativestrict
|
||||
fi
|
||||
|
||||
|
||||
#region Plugins
|
||||
# Clone plugins if not exists
|
||||
[ -d $ZSH_DATA_DIR/plugins/powerlevel10k ] || git clone https://github.com/romkatv/powerlevel10k $ZSH_DATA_DIR/plugins/powerlevel10k
|
||||
[ -d $ZSH_DATA_DIR/plugins/zsh-syntax-highlighting ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_DATA_DIR/plugins/zsh-syntax-highlighting
|
||||
[ -d $ZSH_DATA_DIR/plugins/zsh-history-substring-search ] || git clone https://github.com/zsh-users/zsh-history-substring-search.git $ZSH_DATA_DIR/plugins/zsh-history-substring-search
|
||||
[ -d $ZSH_DATA_DIR/plugins/zsh-autosuggestions ] || git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_DATA_DIR/plugins/zsh-autosuggestions
|
||||
|
||||
source ${ZSH_DATA_DIR}/plugins/powerlevel10k/powerlevel10k.zsh-theme
|
||||
|
||||
source ${ZSH_DATA_DIR}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
source ${ZSH_DATA_DIR}/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
|
||||
source ${ZSH_DATA_DIR}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
#endregion
|
||||
|
||||
#region SUBSTRING SEARCH
|
||||
history-substring-search-up-prefixed(){
|
||||
HISTORY_SUBSTRING_SEARCH_PREFIXED=1 history-substring-search-up
|
||||
}
|
||||
history-substring-search-down-prefixed(){
|
||||
HISTORY_SUBSTRING_SEARCH_PREFIXED=1 history-substring-search-down
|
||||
}
|
||||
|
||||
zle -N history-substring-search-up-prefixed
|
||||
zle -N history-substring-search-down-prefixed
|
||||
#endregion
|
||||
|
||||
#region Init Variables
|
||||
export SAVEHIST=100000
|
||||
export HISTSIZE=$SAVEHIST
|
||||
export ZSH_PRIVATE=${ZSH_PRIVATE:-0}
|
||||
|
||||
mkdir -p $ZSH_DATA_DIR
|
||||
mkdir -p $ZSH_DATA_DIR/plugins
|
||||
|
||||
# Load config generated by nix
|
||||
[[ -f "$ZSH_DATA_DIR/nix.sh" ]] && source "$ZSH_DATA_DIR/nix.sh"
|
||||
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
setopt HIST_IGNORE_DUPS
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
setopt EXTENDED_HISTORY
|
||||
|
||||
# Private history mode
|
||||
if [[ $ZSH_PRIVATE == 1 ]] then
|
||||
export HISTFILE="/dev/null";
|
||||
unsetopt SHARE_HISTORY;
|
||||
else
|
||||
export HISTFILE="$ZSH_DATA_DIR/zsh_history";
|
||||
setopt SHARE_HISTORY;
|
||||
fi
|
||||
#endregion
|
||||
|
||||
|
||||
#region Bindings
|
||||
source ${ZSH_CONFIG_DIR}/extra/zinputrc
|
||||
|
||||
bindkey -r "^["
|
||||
bindkey "^[[1;5C" forward-word
|
||||
bindkey "^[[1;5D" backward-word
|
||||
bindkey "^[[1;5A" history-substring-search-up-prefixed
|
||||
bindkey "^[[1;5B" history-substring-search-down-prefixed
|
||||
bindkey "$key[Up]" history-substring-search-up
|
||||
bindkey "$key[Down]" history-substring-search-down
|
||||
bindkey '^[[3~' delete-char
|
||||
bindkey '^[[3;2~' delete-word
|
||||
#endregion
|
||||
|
||||
#region Completions
|
||||
ZSH_COMPDIR="${ZSH_COMPDIR:-${XDG_CACHE_HOME:-${HOME}/.cache}/zsh}"
|
||||
ZSH_COMPDUMP="${ZSH_COMPDUMP:-${ZSH_COMPDIR}/.zcompdump-${HOST}-${ZSH_VERSION}}"
|
||||
if [[ ! -d ${ZSH_COMPDIR} ]]; then
|
||||
command mkdir -p "${ZSH_COMPDIR}"
|
||||
fi
|
||||
autoload -U compinit && compinit -d $ZSH_COMPDUMP
|
||||
source ${ZSH_CONFIG_DIR}/extra/zshcompletion.zsh
|
||||
#endregion
|
||||
|
||||
#region Functions
|
||||
zsh-private() {
|
||||
ZSH_PRIVATE=1 zsh
|
||||
}
|
||||
|
||||
myip() {
|
||||
wget -qO- https://wtfismyip.com/text
|
||||
}
|
||||
|
||||
speedtest() {
|
||||
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Aliases
|
||||
if [[ "$TERM" = "xterm-kitty" ]]; then
|
||||
alias ssh="kitty +kitten ssh"
|
||||
fi
|
||||
if [[ $(whence -p "nvim") ]]; then
|
||||
EDITOR="${EDITOR:-nvim}"
|
||||
alias vim="nvim"
|
||||
alias vi="nvim"
|
||||
alias vimdiff="nvim -d"
|
||||
fi
|
||||
|
||||
#endregion
|
||||
|
||||
if [[ "$__MATERUS_ZSH_256COLORS" = "1" ]] ; then [[ ! -f ${ZSH_CONFIG_DIR}/p10kcfg/fullcolor.zsh ]] || source ${ZSH_CONFIG_DIR}/p10kcfg/fullcolor.zsh;
|
||||
else [[ ! -f ${ZSH_CONFIG_DIR}/p10kcfg/compatibility.zsh ]] || source ${ZSH_CONFIG_DIR}/p10kcfg/compatibility.zsh;
|
||||
fi
|
||||
Reference in New Issue
Block a user