Fix zsh
This commit is contained in:
@ -1,106 +1,35 @@
|
|||||||
####
|
source $ZDOTDIR/config.zsh
|
||||||
## zsh configuration
|
|
||||||
####
|
|
||||||
|
|
||||||
## Environment
|
if [ ! -d "$ZGEN_DIR" ]; then
|
||||||
export GPG_TTY=$TTY
|
echo "Installing jandamm/zgenom"
|
||||||
|
git clone https://github.com/jandamm/zgenom "$ZGEN_DIR"
|
||||||
|
fi
|
||||||
|
source $ZGEN_DIR/zgenom.zsh
|
||||||
|
|
||||||
## Aliases
|
zgenom autoupdate
|
||||||
source "$ZDOTDIR/aliases.zsh"
|
|
||||||
|
|
||||||
## Colors
|
if ! zgenom saved; then
|
||||||
autoload -U colors && colors
|
echo "Initializing zgenom"
|
||||||
|
rm -f $ZDOTDIR/*.zwc(N) \
|
||||||
|
$XDG_CACHE_HOME/zsh/*(N) \
|
||||||
|
$ZGEN_INIT.zwc
|
||||||
|
|
||||||
## Completion
|
zgenom load junegunn/fzf shell
|
||||||
setopt HASH_LIST_ALL
|
zgenom load zdharma-continuum/fast-syntax-highlighting
|
||||||
unsetopt AUTO_NAME_DIRS
|
zgenom load zsh-users/zsh-completions src
|
||||||
autoload -Uz compinit
|
zgenom load zsh-users/zsh-autosuggestions
|
||||||
zstyle ':completion:*' menu select
|
zgenom load zsh-users/zsh-history-substring-search
|
||||||
zmodload zsh/complist
|
zgenom load softmoth/zsh-vim-mode
|
||||||
compinit
|
|
||||||
_comp_options+=(globdots) # Include hidden files
|
|
||||||
|
|
||||||
## Directories
|
zgenom save
|
||||||
setopt AUTO_CD
|
zgenom compile $ZDOTDIR
|
||||||
setopt AUTO_PUSHD
|
fi
|
||||||
setopt CDABLE_VARS
|
|
||||||
setopt PUSHD_IGNORE_DUPS
|
|
||||||
setopt PUSHD_SILENT
|
|
||||||
setopt PUSHD_TO_HOME
|
|
||||||
|
|
||||||
## Expansion and globbing
|
## Bootstrap interactive sessions
|
||||||
setopt EXTENDED_GLOB
|
if [[ $TERM != dumb ]]; then
|
||||||
unsetopt GLOB_DOTS
|
autoload -Uz compinit && compinit -u -d $ZSH_CACHE/zcompdump
|
||||||
unsetopt NOMATCH
|
|
||||||
|
|
||||||
## History
|
source $ZDOTDIR/keybinds.zsh
|
||||||
setopt APPEND_HISTORY
|
source $ZDOTDIR/completion.zsh
|
||||||
setopt BANG_HIST
|
source $ZDOTDIR/aliases.zsh
|
||||||
setopt EXTENDED_HISTORY
|
fi
|
||||||
setopt HIST_IGNORE_ALL_DUPS
|
|
||||||
setopt HIST_SAVE_NO_DUPS
|
|
||||||
setopt HIST_VERIFY
|
|
||||||
setopt INC_APPEND_HISTORY_TIME
|
|
||||||
HISTFILE="${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/history"
|
|
||||||
HISTSIZE=1000000
|
|
||||||
SAVEHIST=1000000
|
|
||||||
[[ !( -f "${HISTFILE}" ) ]] && mkdir -p $(dirname ${HISTFILE})
|
|
||||||
|
|
||||||
## I/O
|
|
||||||
setopt INTERACTIVE_COMMENTS
|
|
||||||
setopt MULTIOS
|
|
||||||
unsetopt CLOBBER
|
|
||||||
|
|
||||||
## Jobs
|
|
||||||
setopt LONG_LIST_JOBS
|
|
||||||
setopt AUTO_RESUME
|
|
||||||
unsetopt BG_NICE
|
|
||||||
unsetopt NOTIFY
|
|
||||||
unsetopt HUP
|
|
||||||
unsetopt CHECK_JOBS
|
|
||||||
|
|
||||||
## Shell emulation
|
|
||||||
setopt APPEND_CREATE
|
|
||||||
|
|
||||||
## Prompt
|
|
||||||
PS1="%B%{$fg[magenta]%}%~%{$reset_color%} $%b "
|
|
||||||
|
|
||||||
## Vi mode
|
|
||||||
bindkey -v
|
|
||||||
export KEYTIMEOUT=1
|
|
||||||
|
|
||||||
## Zsh line editor
|
|
||||||
unsetopt BEEP
|
|
||||||
|
|
||||||
|
|
||||||
####
|
|
||||||
## Plugins
|
|
||||||
####
|
|
||||||
|
|
||||||
## Autosuggest
|
|
||||||
# source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh 2>/dev/null
|
|
||||||
|
|
||||||
# ## History substring search
|
|
||||||
# source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh 2>/dev/null
|
|
||||||
# bindkey -M vicmd 'k' history-substring-search-up
|
|
||||||
# bindkey -M vicmd 'j' history-substring-search-down
|
|
||||||
|
|
||||||
# ## Highlighting
|
|
||||||
# source /usr/share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh 2>/dev/null
|
|
||||||
|
|
||||||
# ## Enhanced vim mode
|
|
||||||
# MODE_INDICATOR=""
|
|
||||||
# MODE_CURSOR_VIINS="#b77ee0 blinking bar"
|
|
||||||
# MODE_CURSOR_REPLACE="$MODE_CURSOR_VIINS #ff3334"
|
|
||||||
# MODE_CURSOR_VICMD="#b77ee0 block"
|
|
||||||
# MODE_CURSOR_SEARCH="#e7c547 steady underline"
|
|
||||||
# MODE_CURSOR_VISUAL="$MODE_CURSOR_VICMD steady bar"
|
|
||||||
# MODE_CURSOR_VLINE="$MODE_CURSOR_VISUAL #54ced6"
|
|
||||||
# source /usr/share/zsh/plugins/zsh-vim-mode/zsh-vim-mode.plugin.zsh 2>/dev/null
|
|
||||||
|
|
||||||
|
|
||||||
####
|
|
||||||
## Keybindings
|
|
||||||
####
|
|
||||||
stty stop undef
|
|
||||||
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
|
|
||||||
|
6
modules/shell/zsh/completion.zsh
Normal file
6
modules/shell/zsh/completion.zsh
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
fpath+=( $ZDOTDIR/completions )
|
||||||
|
|
||||||
|
# Don't offer history completion; we have fzf, C-r, and
|
||||||
|
# zsh-history-substring-search for that.
|
||||||
|
ZSH_AUTOSUGGEST_STRATEGY=(completion)
|
||||||
|
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=30
|
99
modules/shell/zsh/config.zsh
Normal file
99
modules/shell/zsh/config.zsh
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
####
|
||||||
|
## zsh configuration
|
||||||
|
####
|
||||||
|
|
||||||
|
## Colors
|
||||||
|
autoload -U colors && colors
|
||||||
|
|
||||||
|
## Completion
|
||||||
|
setopt HASH_LIST_ALL
|
||||||
|
unsetopt AUTO_NAME_DIRS
|
||||||
|
autoload -Uz compinit
|
||||||
|
zstyle ':completion:*' menu select
|
||||||
|
zmodload zsh/complist
|
||||||
|
compinit
|
||||||
|
_comp_options+=(globdots) # Include hidden files
|
||||||
|
|
||||||
|
## Directories
|
||||||
|
setopt AUTO_PUSHD
|
||||||
|
setopt CDABLE_VARS
|
||||||
|
setopt PUSHD_IGNORE_DUPS
|
||||||
|
setopt PUSHD_SILENT
|
||||||
|
setopt PUSHD_TO_HOME
|
||||||
|
unsetopt AUTO_CD
|
||||||
|
|
||||||
|
## Expansion and globbing
|
||||||
|
setopt EXTENDED_GLOB
|
||||||
|
unsetopt GLOB_DOTS
|
||||||
|
unsetopt NOMATCH
|
||||||
|
|
||||||
|
## History
|
||||||
|
HISTFILE="${XDG_CACHE_HOME:-${HOME}/.cache}/zsh/history"
|
||||||
|
HISTSIZE=1000000
|
||||||
|
SAVEHIST=1000000
|
||||||
|
[[ !( -f "${HISTFILE}" ) ]] && mkdir -p $(dirname ${HISTFILE})
|
||||||
|
|
||||||
|
setopt APPEND_HISTORY
|
||||||
|
setopt BANG_HIST
|
||||||
|
setopt EXTENDED_HISTORY
|
||||||
|
setopt HIST_IGNORE_ALL_DUPS
|
||||||
|
setopt HIST_IGNORE_DUPS
|
||||||
|
setopt HIST_IGNORE_SPACE
|
||||||
|
setopt HIST_SAVE_NO_DUPS
|
||||||
|
setopt HIST_VERIFY
|
||||||
|
setopt INC_APPEND_HISTORY_TIME
|
||||||
|
setopt SHARE_HISTORY
|
||||||
|
|
||||||
|
## I/O
|
||||||
|
setopt INTERACTIVE_COMMENTS
|
||||||
|
setopt MULTIOS
|
||||||
|
unsetopt CLOBBER
|
||||||
|
|
||||||
|
## Jobs
|
||||||
|
setopt LONG_LIST_JOBS
|
||||||
|
setopt AUTO_RESUME
|
||||||
|
unsetopt BG_NICE
|
||||||
|
unsetopt NOTIFY
|
||||||
|
unsetopt HUP
|
||||||
|
unsetopt CHECK_JOBS
|
||||||
|
|
||||||
|
## Shell emulation
|
||||||
|
setopt APPEND_CREATE
|
||||||
|
|
||||||
|
## Prompt
|
||||||
|
PS1="%B%{$fg[magenta]%}%~%{$reset_color%} $%b "
|
||||||
|
|
||||||
|
## Window title
|
||||||
|
precmd () { print -Pn "\e]0;%n@%m: %~\a" }
|
||||||
|
preexec () { print -Pn "\e]0;%n@%m: $1\a" }
|
||||||
|
|
||||||
|
## Vi mode
|
||||||
|
bindkey -v
|
||||||
|
export KEYTIMEOUT=1
|
||||||
|
|
||||||
|
## Zsh line editor
|
||||||
|
unsetopt BEEP
|
||||||
|
|
||||||
|
|
||||||
|
####
|
||||||
|
## Plugins
|
||||||
|
####
|
||||||
|
|
||||||
|
export ZGEN_AUTOLOAD_COMPINIT=0
|
||||||
|
|
||||||
|
# zsh-vim-mode
|
||||||
|
export MODE_INDICATOR=""
|
||||||
|
export MODE_CURSOR_VIINS="#b77ee0 blinking bar"
|
||||||
|
export MODE_CURSOR_REPLACE="$MODE_CURSOR_VIINS #ff3334"
|
||||||
|
export MODE_CURSOR_VICMD="#b77ee0 block"
|
||||||
|
export MODE_CURSOR_SEARCH="#e7c547 steady underline"
|
||||||
|
export MODE_CURSOR_VISUAL="$MODE_CURSOR_VICMD steady bar"
|
||||||
|
export MODE_CURSOR_VLINE="$MODE_CURSOR_VISUAL #54ced6"
|
||||||
|
|
||||||
|
# fzf
|
||||||
|
if (( $+commands[fd] )); then
|
||||||
|
export FZF_DEFAULT_OPTS="--reverse --ansi"
|
||||||
|
export FZF_DEFAULT_COMMAND="fd ."
|
||||||
|
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
||||||
|
export FZF_ALT_C_COMMAND="fd -t d . $HOME"
|
||||||
|
fi
|
@ -14,6 +14,8 @@ in {
|
|||||||
programs.zsh = {
|
programs.zsh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableCompletion = true;
|
enableCompletion = true;
|
||||||
|
enableGlobalCompInit = false;
|
||||||
|
promptInit = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
user.packages = with pkgs; [
|
user.packages = with pkgs; [
|
||||||
@ -24,19 +26,25 @@ in {
|
|||||||
nnn
|
nnn
|
||||||
ripgrep
|
ripgrep
|
||||||
zsh
|
zsh
|
||||||
zsh-autosuggestions
|
|
||||||
zsh-fast-syntax-highlighting
|
|
||||||
zsh-history-substring-search
|
|
||||||
];
|
];
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
ZDOTDIR = "$XDG_CONFIG_HOME/zsh";
|
ZDOTDIR = "$XDG_CONFIG_HOME/zsh";
|
||||||
ZSH_CACHE = "$XDG_CACHE_HOME/zsh";
|
ZSH_CACHE = "$XDG_CACHE_HOME/zsh";
|
||||||
|
ZGEN_DIR = "$XDG_DATA_HOME/zgenom";
|
||||||
};
|
};
|
||||||
|
|
||||||
home.configFile = {
|
home.configFile = {
|
||||||
"zsh/.zshrc" = { source = ./.zshrc; };
|
"zsh/.zshrc".source = ./.zshrc;
|
||||||
"zsh/aliases.zsh" = { source = ./aliases.zsh; };
|
"zsh/aliases.zsh".source = ./aliases.zsh;
|
||||||
|
"zsh/completion.zsh".source = ./completion.zsh;
|
||||||
|
"zsh/config.zsh".source = ./config.zsh;
|
||||||
|
"zsh/keybinds.zsh".source = ./keybinds.zsh;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system.userActivationScripts.cleanupZgen = ''
|
||||||
|
rm -rf $ZSH_CACHE
|
||||||
|
rm -fv $ZGEN_DIR/init.zsh{,.zwc}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
12
modules/shell/zsh/keybinds.zsh
Normal file
12
modules/shell/zsh/keybinds.zsh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
####
|
||||||
|
## Keybindings
|
||||||
|
####
|
||||||
|
stty stop undef
|
||||||
|
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
|
||||||
|
|
||||||
|
bindkey -M vicmd 'k' history-substring-search-up
|
||||||
|
bindkey -M vicmd 'j' history-substring-search-down
|
||||||
|
|
||||||
|
if (( $+commands[fzf] )); then
|
||||||
|
bindkey '^R' fzf-history-widget
|
||||||
|
fi
|
Reference in New Issue
Block a user