48 lines
1.7 KiB
Nix
48 lines
1.7 KiB
Nix
{config, lib, pkgs, inputs, ...} : {
|
||
programs.bash.enable = true;
|
||
programs.bash.bashrcExtra = ''
|
||
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
|
||
|
||
eval "$(direnv hook bash)"
|
||
'';
|
||
programs.bash.shellAliases = {
|
||
chmod = "chmod --preserve-root";
|
||
chown = "chown --preserve-root";
|
||
ls = "ls -Isnap --color";
|
||
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 = ''
|
||
nixos-rebuild switch --flake "$HOME/.local/os#" --use-remote-sudo
|
||
'';
|
||
":r" = "!!";
|
||
};
|
||
programs.bash.sessionVariables = {
|
||
NIX_SHELL_PRESERVE_PROMPT = 1;
|
||
NIXPKGS_ALLOW_UNFREE = 1;
|
||
};
|
||
} |