-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manage bash with home-manager (#228)
* Manage bash with home-manager * Manage whole bash config with home-manager for now * Tired in nix with bash problems * Needless since bashInteractive in each repo(annoy) * Looks like redundant aliases * Replace cleanup codes with backup option as `makers apply` * Remove outdated comment
- Loading branch information
Showing
11 changed files
with
183 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ config, ... }: | ||
|
||
{ | ||
programs.starship.enableBashIntegration = true; | ||
programs.direnv.enableBashIntegration = true; | ||
programs.zoxide.enableBashIntegration = true; | ||
programs.fzf.enableBashIntegration = true; | ||
programs.rtx.enableBashIntegration = true; | ||
|
||
# Used only in bash - https://unix.stackexchange.com/a/689403 | ||
# https://github.com/nix-community/home-manager/blob/master/modules/programs/readline.nix | ||
programs.readline = { | ||
enable = true; | ||
variables = { | ||
# https://man.archlinux.org/man/readline.3#bell | ||
# option: audible, visible, none | ||
# https://unix.stackexchange.com/questions/73672/how-to-turn-off-the-beep-only-in-bash-tab-complete | ||
# https://github.com/nix-community/home-manager/blob/0841242b94638fcd010f7f64e56b7b1cad50c697/modules/programs/readline.nix | ||
bell-style = "none"; | ||
|
||
# https://wiki.archlinux.jp/index.php/Readline | ||
# https://man.archlinux.org/man/readline.3 | ||
completion-ignore-case = true; | ||
colored-stats = true; | ||
colored-completion-prefix = true; | ||
visible-stats = true; | ||
show-mode-in-prompt = false; | ||
show-all-if-ambiguous = true; | ||
echo-control-characters = false; | ||
}; | ||
}; | ||
|
||
# https://github.com/nix-community/home-manager/blob/master/modules/programs/bash.nix | ||
programs.bash = { | ||
enable = true; | ||
|
||
sessionVariables = { | ||
# Cannot dynamically get from program.readline and cannot use XDG style in home-manager | ||
# https://github.com/nix-community/home-manager/blob/0841242b94638fcd010f7f64e56b7b1cad50c697/modules/programs/readline.nix#L72 | ||
INPUTRC = "${config.home.homeDirectory}/.inputrc"; | ||
}; | ||
|
||
shellOptions = [ | ||
# Append to history file rather than replacing it. | ||
"histappend" | ||
|
||
# check the window size after each command and, if | ||
# necessary, update the values of LINES and COLUMNS. | ||
"checkwinsize" | ||
|
||
# Extended globbing. | ||
"extglob" | ||
"globstar" | ||
|
||
# Warn if closing shell with running jobs. | ||
"checkjobs" | ||
]; | ||
|
||
enableCompletion = true; | ||
|
||
historySize = 100000; | ||
historyFile = "${config.xdg.stateHome}/bash/history"; | ||
historyFileSize = 4200000; | ||
historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; | ||
historyIgnore = [ "ls" "cd" "z" ]; | ||
|
||
# Extracting because embedded here requires complex escape with nix multiline. | ||
initExtra = builtins.readFile ./initExtra.bash; | ||
|
||
logoutExtra = '' | ||
# when leaving the console clear the screen to increase privacy | ||
if [ "$SHLVL" = 1 ]; then | ||
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q | ||
fi | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# https://github.com/Bash-it/bash-it/blob/00062bfcb6c6a68cd2c9d2c76ed764e01e930e87/plugins/available/history-substring-search.plugin.bash | ||
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then | ||
bind '"\e[A":history-substring-search-backward' | ||
bind '"\e[B":history-substring-search-forward' | ||
fi | ||
|
||
# set variable identifying the chroot you work in (used in the prompt below) | ||
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then | ||
debian_chroot=$(cat /etc/debian_chroot) | ||
fi | ||
|
||
# set a fancy prompt (non-color, unless we know we "want" color) | ||
case "$TERM" in | ||
xterm-color | *-256color) color_prompt=yes ;; | ||
esac | ||
|
||
# uncomment for a colored prompt, if the terminal has the capability; turned | ||
# off by default to not distract the user: the focus in a terminal window | ||
# should be on the output of commands, not on the prompt | ||
#force_color_prompt=yes | ||
|
||
if [ -n "$force_color_prompt" ]; then | ||
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | ||
# We have color support; assume it's compliant with Ecma-48 | ||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such | ||
# a case would tend to support setf rather than setaf.) | ||
color_prompt=yes | ||
else | ||
color_prompt= | ||
fi | ||
fi | ||
|
||
if [ "$color_prompt" = yes ]; then | ||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[\033[01;34m\]\w\[\033[00m\]\$ ' | ||
else | ||
PS1='${debian_chroot:+($debian_chroot)}\w\$ ' | ||
fi | ||
unset color_prompt force_color_prompt | ||
|
||
# If this is an xterm set the title to user@host:dir | ||
case "$TERM" in | ||
xterm* | rxvt*) | ||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)} \w\a\]$PS1" | ||
;; | ||
*) ;; | ||
|
||
esac | ||
|
||
# https://github.com/starship/starship/blob/0d98c4c0b7999f5a8bd6e7db68fd27b0696b3bef/docs/uk-UA/advanced-config/README.md#change-window-title | ||
function set_win_title() { | ||
echo -ne "\033]0; $(basename "$PWD") \007" | ||
} | ||
# shellcheck disable=SC2034 | ||
starship_precmd_user_func="set_win_title" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.