From b2b8230678e6e2ac7bf87784f4157cc55bcf8aeb Mon Sep 17 00:00:00 2001 From: tomoron Date: Tue, 25 Feb 2025 12:11:01 +0100 Subject: [PATCH] add bash go back as an option to disable it on server --- homeConfigs/home.nix | 16 +--------------- homeConfigs/hosts/ft.nix | 2 -- homeConfigs/hosts/server.nix | 2 +- homeConfigs/modules/bash.nix | 24 ++++++++++++++++++++++++ 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 homeConfigs/modules/bash.nix diff --git a/homeConfigs/home.nix b/homeConfigs/home.nix index e342951..bd33b67 100644 --- a/homeConfigs/home.nix +++ b/homeConfigs/home.nix @@ -6,7 +6,7 @@ # By: tomoron +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/10/17 18:15:38 by tomoron #+# #+# # -# Updated: 2025/02/14 16:44:45 by tomoron ### ########.fr # +# Updated: 2025/02/25 12:03:56 by tomoron ### ########.fr # # # # **************************************************************************** # @@ -53,20 +53,6 @@ historyControl = ["ignoreboth"]; historyIgnore = [ "ls" "cd" "exit" ]; shellOptions = [ "cdspell" "autocd"]; - bashrcExtra = '' - cd() { - builtin cd "$@" - echo -n "$PWD" > ~/.last_directory - } - [ -z "\$${PS1:-}" ] && return - - if [ -f ~/.last_directory ];then - echo -n going to - cat ~/.last_directory - echo - builtin cd "$(cat ~/.last_directory)" - fi - ''; }; home.sessionPath = [ "~/.local/bin" ]; diff --git a/homeConfigs/hosts/ft.nix b/homeConfigs/hosts/ft.nix index 48b5f6f..ee7467b 100644 --- a/homeConfigs/hosts/ft.nix +++ b/homeConfigs/hosts/ft.nix @@ -1,8 +1,6 @@ { config, lib, pkgs, username,homeDir, ... }: { - imports = []; - home.packages = with pkgs;[ neovim dmenu diff --git a/homeConfigs/hosts/server.nix b/homeConfigs/hosts/server.nix index 46826ec..8353edd 100644 --- a/homeConfigs/hosts/server.nix +++ b/homeConfigs/hosts/server.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: { - + mods.bash.goback = false; wayland.windowManager.hyprland.settings = { monitor= [ "virt-1, 1920x1080@60, 0x0, 1.0" diff --git a/homeConfigs/modules/bash.nix b/homeConfigs/modules/bash.nix new file mode 100644 index 0000000..17573b1 --- /dev/null +++ b/homeConfigs/modules/bash.nix @@ -0,0 +1,24 @@ +{ lib, config, ...}: + +{ + options.mods.bash.goback = lib.mkOption{ + type = lib.types.bool; + default = true; + description = "go back to last cd when starting bash"; + }; + + config.programs.bash.bashrcExtra = lib.mkIf config.mods.bash.goback '' + cd() { + builtin cd "$@" + echo -n "$PWD" > ~/.last_directory + } + [ -z "\$${PS1:-}" ] && return + + if [ -f ~/.last_directory ];then + echo -n going to + cat ~/.last_directory + echo + builtin cd "$(cat ~/.last_directory)" + fi + ''; +}