diff --git a/cells/homemanager/home.nix b/cells/homemanager/home.nix index 2971a22..e92b50c 100644 --- a/cells/homemanager/home.nix +++ b/cells/homemanager/home.nix @@ -64,6 +64,11 @@ in { allowUnsupportedSystem = true; } ''; + + file.".config/fzf-git.sh".text = builtins.readFile (builtins.fetchurl { + url = "https://raw.githubusercontent.com/junegunn/fzf-git.sh/master/fzf-git.sh"; + sha256 = "10h7lhf99jdmzwxl0v0qvild0cr0cx5kv8kanni8w1v1vbh47pjd"; + }); }; programs = cell.programs.default homeDirectory user; diff --git a/cells/homemanager/packages.nix b/cells/homemanager/packages.nix index 0d1377d..2f82ee6 100644 --- a/cells/homemanager/packages.nix +++ b/cells/homemanager/packages.nix @@ -16,11 +16,13 @@ in { [ ansible awscli2 + bat cachix delve direnv dive envsubst + fd gh git-open gnupg diff --git a/cells/homemanager/programs/zsh.nix b/cells/homemanager/programs/zsh.nix index 41fecb4..badba80 100644 --- a/cells/homemanager/programs/zsh.nix +++ b/cells/homemanager/programs/zsh.nix @@ -60,6 +60,19 @@ # krew export PATH="$HOME/.krew/bin:$PATH" # End krew + # fzf. + _fzf_comprun() { + local command=$1 + shift + case "$command" in + cd) fzf --preview 'tree -C {} | head -200' "$@" ;; + export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;; + ssh) fzf --preview 'dig {}' "$@" ;; + *) fzf --preview 'bat -n --color=always {} --line-range :500 {}' "$@" ;; + esac + } + source ~/.config/fzf-git.sh + # End fzf ''; initExtra = '' @@ -88,10 +101,32 @@ else "" ); }; - + bat = { + enable = true; + config = { + theme = "Dracula"; + }; + themes = { + dracula = { + src = inputs.nixpkgs.fetchFromGitHub { + owner = "dracula"; + repo = "sublime"; # Bat uses sublime syntax for its themes + rev = "26c57ec282abcaa76e57e055f38432bd827ac34e"; + sha256 = "019hfl4zbn4vm4154hh3bwk6hm7bdxbr1hdww83nabxwjn99ndhv"; + }; + file = "Dracula.tmTheme"; + }; + }; + }; fzf = { enable = true; enableZshIntegration = true; + defaultCommand = "fd --type file --follow --hidden --color=always --exclude .git"; + defaultOptions = ["--ansi" "--bind ctrl-j:preview-up,ctrl-k:preview-down,ctrl-u:preview-half-page-up,ctrl-p:preview-half-page-down"]; + fileWidgetCommand = "fd --type file --follow --hidden --color=always --exclude .git"; + fileWidgetOptions = ["--ansi" "--preview-window 'right:57%'" "--preview 'bat -n --color=always --line-range :500 {}'"]; + changeDirWidgetCommand = "fd --type=d --follow --hidden --color=always --exclude .git"; + changeDirWidgetOptions = ["--ansi"]; }; nix-index = { enable = true;