From 88a10686f7cd9e15feb8d3464c20749dbd51f7c4 Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Fri, 29 Sep 2023 20:22:05 -0700 Subject: zsh: vim mode --- darwin/home.nix | 53 +++++++++++++++++++++++++++++++++------- hosts/morpheus/configuration.nix | 1 + hosts/oracle/configuration.nix | 13 ++++++---- 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/darwin/home.nix b/darwin/home.nix index ffed46f..e0b1bb0 100644 --- a/darwin/home.nix +++ b/darwin/home.nix @@ -27,6 +27,7 @@ kubectl kubelogin-oidc terraform + kops k9s kubernetes-helm python38 @@ -45,7 +46,7 @@ home.sessionVariables = { PATH = "$PATH:$HOME/.bin"; - VISUAL = "nvim"; + EDITOR = "nvim"; MANPAGER = "nvim +Man!"; }; @@ -53,22 +54,56 @@ programs.zsh = { enable = true; enableCompletion = true; + enableAutosuggestions = true; + dotDir = ".zsh"; + history = { + ignoreAllDups = true; + path = "$HOME/.zsh/history"; + }; + initExtra = '' + zstyle ':completion:*' menu select + zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' + zmodload zsh/complist + 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 + bindkey '^f' autosuggest-accept + source ${pkgs.zsh-vi-mode}/share/zsh-vi-mode/zsh-vi-mode.plugin.zsh + zvm_after_init_commands+=('source ${pkgs.fzf}/share/fzf/completion.zsh && source ${pkgs.fzf}/share/fzf/key-bindings.zsh') + ''; shellAliases = { - ll = "ls -l"; + ".." = "cd .."; + l = "ls --color -al"; + ls = "ls --color"; v = "nvim"; o = "xdg-open"; t = "tmux"; f = "lf"; + tf = "terraform"; + k = "kubectl"; + gst = "git status --short"; + ga = "git add"; + gp = "git push"; + gl = "git log --oneline --decorate --graph"; + gc = "git commit -v -S"; + gd = "git diff --minimal"; }; - oh-my-zsh = { - enable = true; - plugins = [ "git" "kubectl" "sudo" "terraform" "kops" ]; - theme = "robbyrussell"; - }; + plugins = [ + { + name = "pure"; + src = pkgs.fetchFromGitHub { + owner = "sindresorhus"; + repo = "pure"; + rev = "v1.22.0"; + sha256 = "177vabhvgrxdcwvc29rmfmfr96wl75hrkhymnd8qcaky2v4047jd"; + }; + } + ]; }; programs.fzf = { enable = true; - enableZshIntegration = true; + enableZshIntegration = false; defaultOptions = [ "--height 40%" "--layout=reverse" "--border" ]; }; programs.git = { @@ -106,7 +141,7 @@ open = '' %{{ case $(file --mime-type -Lb $f) in - text/*) lf -remote "send $id \$$VISUAL \$fx";; + text/*) lf -remote "send $id \$$EDITOR \$fx";; *) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;; esac }} diff --git a/hosts/morpheus/configuration.nix b/hosts/morpheus/configuration.nix index 7b39b4b..395494c 100644 --- a/hosts/morpheus/configuration.nix +++ b/hosts/morpheus/configuration.nix @@ -18,6 +18,7 @@ ''; }; + environment.pathsToLink = ["/share/zsh"]; system.activationScripts.applications.text = pkgs.lib.mkForce ( '' echo "setting up ~/Applications..." >&2 diff --git a/hosts/oracle/configuration.nix b/hosts/oracle/configuration.nix index 500906b..9782959 100644 --- a/hosts/oracle/configuration.nix +++ b/hosts/oracle/configuration.nix @@ -35,11 +35,14 @@ nixpkgs.config.allowUnfree = true; - environment.systemPackages = with pkgs; [ - neovim - git - interception-tools - ]; + environment = { + pathsToLink = ["/share/zsh"]; + systemPackages = with pkgs; [ + neovim + git + interception-tools + ]; + }; services = { xserver = { -- cgit v1.2.3