{config, lib, pkgs, inputs, os, ...} : { programs.bash.enable = true; programs.bash.bashrcExtra = lib.concatStrings [ '' if [ -n "$PS1" ]; then NEW_PROMPT_COMMAND=' MY_PWD="$PWD" [[ "$MY_PWD" =~ ^"$HOME"(/|$) ]] && MY_PWD="~''${MY_PWD#$HOME}" TRIMMED_PWD=''${MY_PWD: -40}; TRIMMED_PWD=''${TRIMMED_PWD:-$MY_PWD} [[ "''${#MY_PWD}" -ge 41 ]] && TRIMMED_PWD="…$TRIMMED_PWD" SHELL_PREFIX="" [[ -n "$IN_NIX_SHELL" ]] && SHELL_PREFIX="$SHELL_PREFIX " [[ -n "$AWS_VAULT" ]] && SHELL_PREFIX="$SHELL_PREFIX 🔓︎" [[ -n "$FLUTTER_ENV" ]] && SHELL_PREFIX="$SHELL_PREFIX ✌︎" [[ -n "$REACTNATIVE_ENV" ]] && SHELL_PREFIX="$SHELL_PREFIX ⚛" ' if [ -n "''${PROMPT_COMMAND// /}" ]; then PROMPT_COMMAND="$PROMPT_COMMAND $NEW_PROMPT_COMMAND" else PROMPT_COMMAND="$NEW_PROMPT_COMMAND" fi unset NEW_PROMPT_COMMAND export PS1="[\t \[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\]]"'$SHELL_PREFIX'" \[\e[36m\]"'$TRIMMED_PWD'"\[\e[m\] \$ " fi '' # On mac we have to import brew (if (os == "darwin") then '' eval "$(/opt/homebrew/bin/brew shellenv)" '' else '' '') ]; programs.bash.shellAliases = { chmod = "chmod --preserve-root"; chown = "chown --preserve-root"; ls = "ls --color=auto"; df = "df -h -x squashfs -x tmpfs -x devtmpfs -x overlay -x revokefs-fuse"; free = "free -h"; toupper = "tr [:lower:] [:upper:]"; tolower = "tr [:upper:] [:lower:]"; rebuild = if (os == "linux") then '' cd $HOME/.local/os && git pull && nix flake update --commit-lock-file && nixos-rebuild switch --flake "path:$HOME/.local/os#" --use-remote-sudo && git add . && git commit -m "update" && git push && cd - '' else '' cd $HOME/.local/os && git pull && nix flake update --commit-lock-file && home-manager switch && git add . && git commit -m "update" && git push && cd - ''; ":r" = "!!"; ":wq" = "exit"; vim = "hx"; }; programs.bash.sessionVariables = { NIX_SHELL_PRESERVE_PROMPT = 1; NIXPKGS_ALLOW_UNFREE = 1; HISTCONTROL = "ignoreboth:erasedups"; }; }