From c56f402383491ee2841ea64edf2022ba361d0b87 Mon Sep 17 00:00:00 2001 From: multi Date: Mon, 23 Nov 2020 09:34:20 +0000 Subject: feat(users/multi/home): add readline configuration and nix-shell handling to bashrc. This adds my standard inputrc to my home-manager configuration, via the latter's readline module, and adds nix-shell detection to my bash prompt string. Additionally, nix-shell is wrapped in a shell function, so that entering a nix-shell environment automatically runs bash as a subprocess where appropriate, as the default environment spawned by nix-shell is not to my liking. Change-Id: Id5b1b9415a185ad9920f268c66de32d6ccc0b452 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2146 Reviewed-by: multi Tested-by: BuildkiteCI --- users/multi/home/configs/whitby.nix | 43 ++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'users/multi') diff --git a/users/multi/home/configs/whitby.nix b/users/multi/home/configs/whitby.nix index 1ed95770f7a3..9d455a177185 100644 --- a/users/multi/home/configs/whitby.nix +++ b/users/multi/home/configs/whitby.nix @@ -19,16 +19,53 @@ in bash = { enable = true; initExtra = '' - bind '"\e[5~":history-search-backward' - bind '"\e[6~":history-search-forward' + PS1="[\\u@\\h:\\w" + if [[ -n "$IN_NIX_SHELL" ]]; then + PS1="$PS1 (nix-shell)]\\\$ " + else + PS1="$PS1]\\\$ " + fi - PS1="[\\u@\\h:\\w]\\\$ " + nix-shell() { + local comarg=0 + for i in "$@"; do + [[ "$i" == "--command" ]] && comarg=1 + done + + if (( commarg == 0 )); then + command nix-shell --command bash "$@" + else + command nix-shell "$@" + fi + } _Z_CMD=d source ~/.z.sh ''; }; + readline = { + enable = true; + bindings = { + "\\e[5~" = "history-search-backward"; + "\\e[6~" = "history-search-forward"; + "\\C-w" = "\"\\e\\C-h\""; + }; + includeSystemConfig = false; + variables = { + expand-tilde = true; + colored-stats = true; + page-completions = false; + menu-complete-display-prefix = true; + colored-completion-prefix = true; + completion-query-items = 0; + completion-ignore-case = true; + revert-all-at-newline = true; + show-all-if-ambiguous = true; + skip-completed-text = true; + }; + }; + tmux = { enable = true; terminal = "tmux-256color"; -- cgit 1.4.1