add bash go back as an option to disable it on server

This commit is contained in:
2025-02-25 12:11:01 +01:00
parent 00e482e95c
commit b2b8230678
4 changed files with 26 additions and 18 deletions

View File

@ -6,7 +6,7 @@
# By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# 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" ];

View File

@ -1,8 +1,6 @@
{ config, lib, pkgs, username,homeDir, ... }:
{
imports = [];
home.packages = with pkgs;[
neovim
dmenu

View File

@ -1,7 +1,7 @@
{ config, lib, pkgs, ... }:
{
mods.bash.goback = false;
wayland.windowManager.hyprland.settings = {
monitor= [
"virt-1, 1920x1080@60, 0x0, 1.0"

View File

@ -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
'';
}