From 968518609f6d4cc7c3191e3321f122fc843b2edd Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Tue, 18 Jan 2022 10:33:23 +0100 Subject: [PATCH] adjusted zsh config --- home/zsh/common.nix | 39 +++++++++++++++++++- home/zsh/default.nix | 46 +++--------------------- home/zsh/macos.nix | 86 ++++++++++++-------------------------------- 3 files changed, 64 insertions(+), 107 deletions(-) diff --git a/home/zsh/common.nix b/home/zsh/common.nix index 2333345..368ecc4 100644 --- a/home/zsh/common.nix +++ b/home/zsh/common.nix @@ -27,6 +27,7 @@ # enableAliases = true; }; programs.zsh = { + enable = true; enableAutosuggestions = true; enableCompletion = true; initExtraBeforeCompInit = '' @@ -41,7 +42,6 @@ zstyle ':completion:*' menu select ''; enableSyntaxHighlighting = true; - enableVteIntegration = true; autocd = true; defaultKeymap = "viins"; history = { @@ -60,5 +60,42 @@ "......" = "../../../../.."; }; localVariables = { KEYTIMEOUT = 1; }; + initExtra = '' + autoload -U history-search-end + zle -N history-beginning-search-backward-end history-search-end + zle -N history-beginning-search-forward-end history-search-end + bindkey "^[[A" history-beginning-search-backward-end + bindkey "^[[B" history-beginning-search-forward-end + # setopt PROMPT_CR + # setopt PROMPT_SP + # export PROMPT_EOL_MARK="" + unsetopt PROMPT_SP + + precmd() { + precmd() { + echo + } + } + + VENV_DIR="${config.home.homeDirectory}/virtualenvs" + export WORKON_HOME="''${VENV_DIR}" + function activate-venv() { + local selected_env + selected_env=$( + ${pkgs.findutils}/bin/find \ + "''${VENV_DIR}" \ + -maxdepth 1 \ + -mindepth 1 \ + -type d \ + -exec basename {} \; | \ + ${pkgs.fzf}/bin/fzf + ) + [ -n "$selected_env" ] && \ + source "''${VENV_DIR}/''${selected_env}/bin/activate" + } + + export LANG=en_US.utf8 + export LC_ALL=en_US.UTF-8 + ''; }; } diff --git a/home/zsh/default.nix b/home/zsh/default.nix index 5e4572f..60c4fcd 100644 --- a/home/zsh/default.nix +++ b/home/zsh/default.nix @@ -2,47 +2,9 @@ { imports = [ ./common.nix ]; - programs.starship = { - settings = { - gcloud = { disabled = true; }; - python = { disabled = true; }; - }; - }; - programs.zsh = { - enable = true; - initExtra = '' - autoload -U history-search-end - zle -N history-beginning-search-backward-end history-search-end - zle -N history-beginning-search-forward-end history-search-end - bindkey "^[[A" history-beginning-search-backward-end - bindkey "^[[B" history-beginning-search-forward-end - # setopt PROMPT_CR - # setopt PROMPT_SP - # export PROMPT_EOL_MARK="" - unsetopt PROMPT_SP - - precmd() { - precmd() { - echo - } - } - - VENV_DIR="${config.home.homeDirectory}/virtualenvs" - export WORKON_HOME="''${VENV_DIR}" - function activate-venv() { - local selected_env - selected_env=$( - ${pkgs.findutils}/bin/find \ - "''${VENV_DIR}" \ - -maxdepth 1 \ - -mindepth 1 \ - -type d \ - -exec basename {} \; | \ - ${pkgs.fzf}/bin/fzf - ) - [ -n "$selected_env" ] && \ - source "''${VENV_DIR}/''${selected_env}/bin/activate" - } - ''; + programs.starship.settings = { + gcloud = { disabled = true; }; + python = { disabled = true; }; }; + programs.zsh.enableVteIntegration = true; } diff --git a/home/zsh/macos.nix b/home/zsh/macos.nix index 302b488..38ec1a0 100644 --- a/home/zsh/macos.nix +++ b/home/zsh/macos.nix @@ -2,70 +2,28 @@ { imports = [ ./common.nix ]; - programs.starship = { - settings = { - gcloud = { - disabled = false; - format = '' - on [$symbol$account(@$domain)(($region))]($style) - ''; - symbol = "☁️ "; - }; - python = { - disabled = true; - symbol = ""; - format = '' - via [$symbol$pyenv_prefix($version )(($virtualenv) )]($style) - ''; - python_binary = [ - "python" - "python2" - "python3" - "/usr/bin/python" - "/usr/local/bin/python3" - ]; - }; + programs.starship.settings = { + gcloud = { + disabled = false; + format = '' + on [$symbol$account(@$domain)(($region))]($style) + ''; + symbol = "☁️ "; + }; + python = { + disabled = true; + symbol = ""; + format = '' + via [$symbol$pyenv_prefix($version )(($virtualenv) )]($style) + ''; + python_binary = [ + "python" + "python2" + "python3" + "/usr/bin/python" + "/usr/local/bin/python3" + ]; }; }; - - programs.zsh = { - enableVteIntegration = false; - initExtra = '' - autoload -U history-search-end - zle -N history-beginning-search-backward-end history-search-end - zle -N history-beginning-search-forward-end history-search-end - bindkey "^[[A" history-beginning-search-backward-end - bindkey "^[[B" history-beginning-search-forward-end - # setopt PROMPT_CR - # setopt PROMPT_SP - # export PROMPT_EOL_MARK="" - unsetopt PROMPT_SP - - precmd() { - precmd() { - echo - } - } - - VENV_DIR="${config.home.homeDirectory}/virtualenvs" - export WORKON_HOME="''${VENV_DIR}" - function activate-venv() { - local selected_env - selected_env=$( - ${pkgs.findutils}/bin/find \ - "''${VENV_DIR}" \ - -maxdepth 1 \ - -mindepth 1 \ - -type d \ - -exec basename {} \; | \ - ${pkgs.fzf}/bin/fzf - ) - [ -n "$selected_env" ] && \ - source "''${VENV_DIR}/''${selected_env}/bin/activate" - } - - export LANG=en_US.utf8 - export LC_ALL=en_US.UTF-8 - ''; - }; + programs.zsh.enableVteIntegration = false; }