From 05e0d67e1a367f1a20639f8f668dc7efc83ec9d0 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 3 Jan 2023 07:57:46 +0100 Subject: [PATCH] Move zshrc extra to own file This allows for proper syntax highlighting This also prevents the need for escaping --- home/files/zshrc | 46 ++++++++++++++++++++++++++++++++++++ home/programs/zsh.nix | 54 ++++--------------------------------------- 2 files changed, 51 insertions(+), 49 deletions(-) create mode 100644 home/files/zshrc diff --git a/home/files/zshrc b/home/files/zshrc new file mode 100644 index 0000000..3bee9f0 --- /dev/null +++ b/home/files/zshrc @@ -0,0 +1,46 @@ +autoload -U colors && colors +autoload -U promptinit +autoload -U complist + +# Set vim mode +set -o vi + +# Allow editing of current line in $EDITOR using command mode V +autoload -U edit-command-line +zle -N edit-command-line +bindkey -M vicmd v edit-command-line + +# ctrl-r search history backward to keep old pattern +bindkey '^r' history-incremental-search-backward +# ctrl-j search history backward to have vim like binding +# TODO: Find out why this breaks within neoterminal when sending commands like from test or repl +# bindkey '^j' history-incremental-search-backward +# # ctrl-k search history forward to have vim like binding +bindkey '^k' history-search-forward + +# also complete defined alias +setopt completealiases +# Correct mistyped commands +setopt correctall +# Try to make the completion list smaller (occupying less lines) by printing the matches in columns with different widths. +setopt list_packed +# When listing files that are possible completions, show the type of each file with a trailing identifying mark. +setopt list_types + +# Allow for functions in the prompt. +setopt PROMPT_SUBST + +PROMPT=$'%{$fg[blue]%}%1~ > %{$reset_color%}' + +zstyle ':completion:*:descriptions' format '%U%B%d%b%u' +zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b' +zstyle ':completion:*' menu select +zstyle ':completion:*' use-cache on +zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS} +zstyle ':completion:*' cache-path ${config.xdg.cacheHome}/zsh-completion/ + +zstyle ':completion:*' group-name ''' +zstyle ':completion::complete:git-checkout:argument-rest:' group-order heads-local heads-remote commit-tags +zstyle ':completion::complete:git-checkout:argument-rest:commits' command 'echo' +zstyle ':completion::complete:git-checkout:argument-rest:valid-ref-names' command 'echo' +zstyle ':completion::complete:git-checkout:argument-rest:remote-branch-refs-noprefix' command 'echo' diff --git a/home/programs/zsh.nix b/home/programs/zsh.nix index 6510ace..8170d91 100644 --- a/home/programs/zsh.nix +++ b/home/programs/zsh.nix @@ -1,5 +1,9 @@ { config, pkgs }: +# Sources: +# https://thevaluable.dev/zsh-install-configure-mouseless/ +# https://thevaluable.dev/zsh-completion-guide-examples/ + { enable = true; @@ -26,53 +30,5 @@ path = "${config.xdg.dataHome}/zsh/zsh_history"; }; - initExtra = '' - autoload -U colors && colors - autoload -U promptinit - autoload -U complist - - # Set vim mode - set -o vi - - # Allow editing of current line in $EDITOR using command mode V - autoload -U edit-command-line - zle -N edit-command-line - bindkey -M vicmd v edit-command-line - - # ctrl-r search history backward to keep old pattern - bindkey '^r' history-incremental-search-backward - # ctrl-j search history backward to have vim like binding - # TODO: Find out why this breaks within neoterminal when sending commands like from test or repl - # bindkey '^j' history-incremental-search-backward - # # ctrl-k search history forward to have vim like binding - bindkey '^k' history-search-forward - - - zstyle ':completion:*:descriptions' format '%U%B%d%b%u' - zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b' - zstyle ':completion:*' menu select - zstyle ':completion:*' use-cache on - zstyle ':completion:*' list-colors ''${(s.:.)LS_COLORS} - zstyle ':completion:*' cache-path ${config.xdg.cacheHome}/zsh-completion/ - - zstyle ':completion:*' group-name ''' - zstyle ':completion::complete:git-checkout:argument-rest:' group-order heads-local heads-remote commit-tags - zstyle ':completion::complete:git-checkout:argument-rest:commits' command 'echo' - zstyle ':completion::complete:git-checkout:argument-rest:valid-ref-names' command 'echo' - zstyle ':completion::complete:git-checkout:argument-rest:remote-branch-refs-noprefix' command 'echo' - - # also complete defined alias - setopt completealiases - # Correct mistyped commands - setopt correctall - # Try to make the completion list smaller (occupying less lines) by printing the matches in columns with different widths. - setopt list_packed - # When listing files that are possible completions, show the type of each file with a trailing identifying mark. - setopt list_types - - # Allow for functions in the prompt. - setopt PROMPT_SUBST - - PROMPT=$'%{$fg[blue]%}%1~ > %{$reset_color%}' - ''; + initExtra = builtins.readFile(../files/zshrc); }