From e3e43adc901f5f221bda7c4f9d9a5dbf45390588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Jatu=C5=BEis?= Date: Sun, 5 Nov 2023 14:19:48 +0200 Subject: [PATCH] move `hcd` to aliases and `he` to a script --- pkgs/default.nix | 1 + pkgs/he.nix | 8 ++++ profiles/cli/default.nix | 81 ++++++++++++++------------------ profiles/cli/fish/init.fish | 8 ---- profiles/cli/nushell/default.nix | 11 ----- profiles/cli/zsh/initExtra.zsh | 8 ---- 6 files changed, 45 insertions(+), 72 deletions(-) create mode 100644 pkgs/he.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index fa634ff8..db9d0990 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -5,6 +5,7 @@ bumblebee-status-source = inputs.bumblebee-status.outPath; }; hunspell-lt = pkgs.callPackage ./hunspell-lt { }; + he = pkgs.callPackage ./he.nix { }; hm-option = pkgs.callPackage ./hm-option.nix { }; hm-repl = pkgs.callPackage ./hm-repl.nix { }; hm-switch = pkgs.callPackage ./hm-switch.nix { diff --git a/pkgs/he.nix b/pkgs/he.nix new file mode 100644 index 00000000..f01d0932 --- /dev/null +++ b/pkgs/he.nix @@ -0,0 +1,8 @@ +{ writeShellScriptBin, fzf }: +writeShellScriptBin "he" '' + cd ~/.config/nixpkgs || exit 1 + readarray -t files < <(${fzf}/bin/fzf --multi) + if [ -n "''${files[0]}" ]; then + exec $EDITOR "''${files[@]}" + fi +'' diff --git a/profiles/cli/default.nix b/profiles/cli/default.nix index 75f7b063..8c89c5ab 100644 --- a/profiles/cli/default.nix +++ b/profiles/cli/default.nix @@ -13,56 +13,47 @@ ./zsh ./nushell ]; - home.packages = (with pkgs; [ - bat - bfs - binutils - cachix - comma - dnsutils - fd - file - git - github-cli - htop - icdiff - jq - lf - lsof - ncdu - niv - nixfmt - nix-index - p7zip - patchelf - ripgrep - shellcheck - statix - tree - unzip - wol - xdg-user-dirs - ]) ++ (with myPkgs; [ hm-repl hm-switch ]); - home.sessionVariables = { - EDITOR = "nvim"; - MANPAGER = "sh -c 'col -bx | bat -l man -p'"; + home = { + packages = (with pkgs; [ + bat + bfs + binutils + cachix + comma + dnsutils + fd + file + git + github-cli + htop + icdiff + jq + lf + lsof + ncdu + niv + nixfmt + nix-index + p7zip + patchelf + ripgrep + shellcheck + statix + tree + unzip + wol + xdg-user-dirs + ]) ++ (with myPkgs; [ he hm-repl hm-switch ]); + sessionVariables = { + EDITOR = "nvim"; + MANPAGER = "sh -c 'col -bx | bat -l man -p'"; + }; + shellAliases.hcd = "cd ~/.config/nixpkgs"; }; programs = { bash = { enable = true; historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; - initExtra = '' - hcd () { - cd ~/.config/nixpkgs || exit 1 - } - he () { - ( - local FILES - hcd && readarray -t FILES <<< "$(fzf --multi)" && [ -n "''${FILES[*]}" ] && "$EDITOR" "''${FILES[@]}" - ) - } - - ''; }; broot.enable = true; exa = { diff --git a/profiles/cli/fish/init.fish b/profiles/cli/fish/init.fish index 344bf9b8..ba7bd501 100644 --- a/profiles/cli/fish/init.fish +++ b/profiles/cli/fish/init.fish @@ -1,11 +1,3 @@ function hcd cd ~/.config/nixpkgs || exit 1 end - -function he - if pushd ~/.config/nixpkgs - set -l FILES (fzf --print0 --multi | string split0) - set -q FILES[1] && $EDITOR $FILES - popd - end -end diff --git a/profiles/cli/nushell/default.nix b/profiles/cli/nushell/default.nix index 0929c7d8..3f004f7f 100644 --- a/profiles/cli/nushell/default.nix +++ b/profiles/cli/nushell/default.nix @@ -58,17 +58,6 @@ ...targets: string@"manpages" ] - alias hcd = cd ~/.config/nixpkgs - - def he [] { - hcd - let files = (fzf --multi | lines) - if not ($files | is-empty) { - run-external $env.EDITOR $files - } - } - - $env.config = { render_right_prompt_on_last_line: true show_banner: false diff --git a/profiles/cli/zsh/initExtra.zsh b/profiles/cli/zsh/initExtra.zsh index 8b7c26ae..6471af07 100644 --- a/profiles/cli/zsh/initExtra.zsh +++ b/profiles/cli/zsh/initExtra.zsh @@ -1,14 +1,6 @@ find-shells () { cat "$XDG_DATA_HOME"/direnv/allow/* | sort | uniq | sed -e 's/\.envrc$/shell.nix/' } -hcd () { - cd ~/.config/nixpkgs || exit 1 -} -he () { - ( - hcd && local FILES=("${(@f)$(fzf --multi)}") && [ -n "${FILES[*]}" ] && "$EDITOR" "${FILES[@]}" - ) -} rebuild_shells () { while read i; do