From 22bf1600b1f529d368039567ab63277aeca7a3b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Schr=C3=B6ter?= Date: Fri, 17 Mar 2023 12:37:26 +0100 Subject: [PATCH] refactor(shell): split shell config --- home/shell/aliases.nix | 1 + home/shell/bash.nix | 9 +++ home/shell/default.nix | 86 +------------------------- home/shell/direnv.nix | 14 +++++ home/shell/{terminal.nix => kitty.nix} | 2 +- home/shell/starship.nix | 18 ++++++ home/shell/zsh.nix | 57 +++++++++++++++++ 7 files changed, 102 insertions(+), 85 deletions(-) create mode 100644 home/shell/aliases.nix create mode 100644 home/shell/bash.nix create mode 100644 home/shell/direnv.nix rename home/shell/{terminal.nix => kitty.nix} (98%) create mode 100644 home/shell/starship.nix create mode 100644 home/shell/zsh.nix diff --git a/home/shell/aliases.nix b/home/shell/aliases.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/home/shell/aliases.nix @@ -0,0 +1 @@ +{ } diff --git a/home/shell/bash.nix b/home/shell/bash.nix new file mode 100644 index 0000000..6373c1c --- /dev/null +++ b/home/shell/bash.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +let shellAliases = import ./aliases.nix; +in { + programs.bash = { + enable = true; + inherit shellAliases; + }; +} diff --git a/home/shell/default.nix b/home/shell/default.nix index 8df2974..34e29b6 100644 --- a/home/shell/default.nix +++ b/home/shell/default.nix @@ -1,92 +1,10 @@ { config, pkgs, ... }: -let shellAliases = { }; -in { - imports = [ ./terminal.nix ]; +{ + imports = [ ./bash.nix ./zsh.nix ./starship.nix ./kitty.nix ./direnv.nix ]; programs.fzf = { enable = true; }; - programs.starship = { - enable = true; - settings = { - add_newline = false; - status.disabled = false; - status.symbol = "❌ "; - aws.disabled = true; - gcloud.disabled = true; - # kitty/neovim don't play well with multi-width emojis - nix_shell.symbol = " "; - }; - }; - - programs.zsh = { - enable = true; - enableAutosuggestions = true; - autocd = true; - defaultKeymap = "viins"; - history.extended = true; - plugins = with pkgs; [ - { - name = "first-tab-completion"; - src = lib.cleanSource ./.; - file = "first-tab-completion.zsh"; - } - { - name = "zsh-syntax-highlighting"; - src = zsh-syntax-highlighting; - file = "share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"; - } - { - name = "zsh-history-substring-search"; - src = zsh-history-substring-search; - file = - "share/zsh-history-substring-search/zsh-history-substring-search.zsh"; - } - ]; - initExtra = with pkgs; '' - export KEYTIMEOUT=1 - - ZSH_AUTOSUGGEST_USE_ASYNC=1 - ZSH_AUTOSUGGEST_STRATEGY=(history completion) - - zmodload zsh/complist - zstyle ':completion:*' menu select - zstyle ':completion:*' insert-tab false - bindkey '^I' first-tab-completion - bindkey -M menuselect '\e' send-break - bindkey -M menuselect "$terminfo[kcbt]" reverse-menu-complete - bindkey -M menuselect 'h' vi-backward-char - bindkey -M menuselect 'k' vi-up-line-or-history - bindkey -M menuselect 'l' vi-forward-char - bindkey -M menuselect 'j' vi-down-line-or-history - - setopt HIST_FIND_NO_DUPS - bindkey "$terminfo[kcuu1]" history-substring-search-up - bindkey "$terminfo[kcud1]" history-substring-search-down - bindkey -M vicmd 'k' history-substring-search-up - bindkey -M vicmd 'j' history-substring-search-down - - setopt extendedglob - setopt kshglob - ''; - inherit shellAliases; - }; - - programs.bash = { - enable = true; - inherit shellAliases; - }; - - programs.direnv = { - enable = true; - nix-direnv.enable = true; - }; - - # for .envrc's in child directories add "source_up" - # for them to pick up this config - home.file."dev/work/.envrc".text = '' - dotenv - ''; home.file."dev/work/.env".text = '' BROWSER=firefox-work ''; diff --git a/home/shell/direnv.nix b/home/shell/direnv.nix new file mode 100644 index 0000000..303967b --- /dev/null +++ b/home/shell/direnv.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: + +{ + programs.direnv = { + enable = true; + nix-direnv.enable = true; + }; + + # for .envrc's in child directories add "source_up" + # for them to pick up this config + home.file."dev/work/.envrc".text = '' + dotenv + ''; +} diff --git a/home/shell/terminal.nix b/home/shell/kitty.nix similarity index 98% rename from home/shell/terminal.nix rename to home/shell/kitty.nix index aea671f..a561160 100644 --- a/home/shell/terminal.nix +++ b/home/shell/kitty.nix @@ -2,7 +2,7 @@ with pkgs; with lib; { - # kitty + # kitty terminal programs.kitty = { enable = true; keybindings = let diff --git a/home/shell/starship.nix b/home/shell/starship.nix new file mode 100644 index 0000000..bae0983 --- /dev/null +++ b/home/shell/starship.nix @@ -0,0 +1,18 @@ +{ config, pkgs, ... }: + +{ + # starship prompt + programs.starship = { + enable = true; + settings = { + add_newline = false; + status.disabled = false; + status.symbol = "❌ "; + aws.disabled = true; + gcloud.disabled = true; + + # kitty/neovim don't play well with multi-width emojis + nix_shell.symbol = " "; + }; + }; +} diff --git a/home/shell/zsh.nix b/home/shell/zsh.nix new file mode 100644 index 0000000..9759fa2 --- /dev/null +++ b/home/shell/zsh.nix @@ -0,0 +1,57 @@ +{ config, pkgs, ... }: + +let shellAliases = import ./aliases.nix; +in { + programs.zsh = { + enable = true; + enableAutosuggestions = true; + autocd = true; + defaultKeymap = "viins"; + history.extended = true; + plugins = with pkgs; [ + { + name = "first-tab-completion"; + src = lib.cleanSource ./.; + file = "first-tab-completion.zsh"; + } + { + name = "zsh-syntax-highlighting"; + src = zsh-syntax-highlighting; + file = "share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"; + } + { + name = "zsh-history-substring-search"; + src = zsh-history-substring-search; + file = + "share/zsh-history-substring-search/zsh-history-substring-search.zsh"; + } + ]; + initExtra = '' + export KEYTIMEOUT=1 + + ZSH_AUTOSUGGEST_USE_ASYNC=1 + ZSH_AUTOSUGGEST_STRATEGY=(history completion) + + zmodload zsh/complist + zstyle ':completion:*' menu select + zstyle ':completion:*' insert-tab false + bindkey '^I' first-tab-completion + bindkey -M menuselect '\e' send-break + bindkey -M menuselect "$terminfo[kcbt]" reverse-menu-complete + bindkey -M menuselect 'h' vi-backward-char + bindkey -M menuselect 'k' vi-up-line-or-history + bindkey -M menuselect 'l' vi-forward-char + bindkey -M menuselect 'j' vi-down-line-or-history + + setopt HIST_FIND_NO_DUPS + bindkey "$terminfo[kcuu1]" history-substring-search-up + bindkey "$terminfo[kcud1]" history-substring-search-down + bindkey -M vicmd 'k' history-substring-search-up + bindkey -M vicmd 'j' history-substring-search-down + + setopt extendedglob + setopt kshglob + ''; + inherit shellAliases; + }; +}