From 287d45e79c05f0ffd83436cfa11614d197478b7a Mon Sep 17 00:00:00 2001 From: cspark Date: Sun, 4 Aug 2024 21:46:50 +0100 Subject: [PATCH] Migrate bash shell aliases to global home configuration, additionally override cd command to implement neovim terminal pwd integration --- configurations/desktop/home.nix | 3 --- configurations/laptop/home.nix | 3 --- global-home.nix | 15 +++++++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/configurations/desktop/home.nix b/configurations/desktop/home.nix index a1485d47..c2d7987b 100644 --- a/configurations/desktop/home.nix +++ b/configurations/desktop/home.nix @@ -89,9 +89,6 @@ }; programs.bash.shellAliases = { - sudo = "sudo "; - doas = "doas "; - edit = "$EDITOR"; nixos-rebuild-system-flake = "sudo nixos-rebuild switch --flake /etc/nixos#desktop"; }; diff --git a/configurations/laptop/home.nix b/configurations/laptop/home.nix index f4c32bb8..1407e0b3 100644 --- a/configurations/laptop/home.nix +++ b/configurations/laptop/home.nix @@ -47,9 +47,6 @@ }; programs.bash.shellAliases = { - sudo = "sudo "; - doas = "doas "; - edit = "$EDITOR"; nixos-rebuild-system-flake = "sudo nixos-rebuild switch --flake /etc/nixos#laptop"; }; diff --git a/global-home.nix b/global-home.nix index b01d434f..b157fc03 100644 --- a/global-home.nix +++ b/global-home.nix @@ -50,6 +50,15 @@ in USBKEYBUSID="$(echo `grep 0930 /sys/bus/usb/devices/*/idVendor | cut -d '/' -f 6`)" sudo usbip unbind -b $USBKEYBUSID '') + + # Scripts to replace user utils with ones that can interface with the neovim inbuilt terminal + (pkgs.writeShellScriptBin "cd-nvim" '' +if [ $1 ]; then + builtin cd "''$(realpath "$1")" && printf "\033]7;file://''${PWD}\033\\" +else + builtin cd "''${HOME}" && printf "\033]7;file://''${PWD}\033\\" +fi + '') # wineWowPackages.full # native wayland support (unstable) @@ -287,6 +296,12 @@ in . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ([[ -z $(tty) ]] && nvim +terminal) || fastfetch ''; + shellAliases = { + sudo = "sudo "; + doas = "doas "; + edit = "$EDITOR"; + cd = "source cd-nvim"; + }; }; programs.git = {