Compare commits
No commits in common. "10c415c3e5d90f462d31a669ce719b0a091001b9" and "70f4f215c07ee582329c96e33c31d02e90f5e3af" have entirely different histories.
10c415c3e5
...
70f4f215c0
1 changed files with 237 additions and 241 deletions
|
|
@ -1,70 +1,66 @@
|
||||||
{ pkgs, ... }:
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
programs.bash = {
|
programs.bash = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableCompletion = false;
|
|
||||||
initExtra = ''
|
initExtra = ''
|
||||||
if [[ ! -v BASH_COMPLETION_VERSINFO ]] &&
|
[ "''${BASH_COMPLETION_VERSINFO-}" ] || unset -v BASH_COMPLETION_VERSINFO
|
||||||
[[ -f "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh" ]]; then
|
|
||||||
source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ "$DISPLAY" ] && xset r rate 300 60
|
[ "$DISPLAY" ] && xset r rate 300 60
|
||||||
|
|
||||||
#-##################### user specific aliases and functions ######################
|
#-##################### user specific aliases and functions ######################
|
||||||
if [ -d ~/.bashrc.d ]; then
|
if [ -d ~/.bashrc.d ]; then
|
||||||
for rc in ~/.bashrc.d/*; do
|
for rc in ~/.bashrc.d/*; do
|
||||||
bn=''${rc##*/}
|
bn=''${rc##*/}
|
||||||
if [ -f "''$rc" ] && [ -r "''$rc" ] && [ ! "''${bn::1}" = '.' ]; then
|
if [ -f "''$rc" ] && [ -r "''$rc" ] && [ ! "''${bn::1}" = '.' ]; then
|
||||||
\. "''$rc"
|
\. "''$rc"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
unset rc bn
|
unset rc bn
|
||||||
|
|
||||||
#-########################### shell settings & options ###########################
|
#-########################### shell settings & options ###########################
|
||||||
set -E
|
set -E
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
shopt -s nullglob dotglob globstar extglob
|
shopt -s nullglob dotglob globstar extglob
|
||||||
shopt -s autocd cdable_vars cdspell
|
shopt -s autocd cdable_vars cdspell
|
||||||
shopt -s checkwinsize
|
shopt -s checkwinsize
|
||||||
shopt -s lastpipe
|
shopt -s lastpipe
|
||||||
shopt -s inherit_errexit
|
shopt -s inherit_errexit
|
||||||
shopt -s no_empty_cmd_completion
|
shopt -s no_empty_cmd_completion
|
||||||
shopt -s histreedit
|
shopt -s histreedit
|
||||||
shopt -s lithist
|
shopt -s lithist
|
||||||
shopt -u histverify
|
shopt -u histverify
|
||||||
_have bash_abbr && shopt -u expand_aliases
|
_have bash_abbr && shopt -u expand_aliases
|
||||||
|
|
||||||
#-############################### shell variables ################################
|
#-############################### shell variables ################################
|
||||||
FIGNORE='.o'
|
FIGNORE='.o'
|
||||||
HISTCONTROL=ignoreboth:erasedups
|
HISTCONTROL=ignoreboth:erasedups
|
||||||
HISTTIMEFORMAT='%y-%m-%d %H:%M:%S '
|
HISTTIMEFORMAT='%y-%m-%d %H:%M:%S '
|
||||||
HISTSIZE=-1
|
HISTSIZE=-1
|
||||||
HISTFILESIZE=-1
|
HISTFILESIZE=-1
|
||||||
HISTFILE=''$HOME/.''${USER:-default}_bash_history
|
HISTFILE=''$HOME/.''${USER:-default}_bash_history
|
||||||
|
|
||||||
#-############################ environment variables #############################
|
#-############################ environment variables #############################
|
||||||
export PYTHON_BASIC_REPL=1 # I'm good at readline so I'm gonna use readline whereever possible!
|
export PYTHON_BASIC_REPL=1 # I'm good at readline so I'm gonna use readline whereever possible!
|
||||||
export LESS='-SRFX'
|
export LESS='-SRFX'
|
||||||
export PAGER='less' GIT_PAGER='less' MANPAGER='less' SYSTEMD_PAGER='less'
|
export PAGER='less' GIT_PAGER='less' MANPAGER='less' SYSTEMD_PAGER='less'
|
||||||
export BAT_PAGER='''
|
export BAT_PAGER='''
|
||||||
export EDITOR='vim' VISUAL='vim' FCEDIT='vim' SYSTEMD_EDITOR='vim'
|
export EDITOR='vim' VISUAL='vim' FCEDIT='vim' SYSTEMD_EDITOR='vim'
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
#-########################## generally useful functions ##########################
|
#-########################## generally useful functions ##########################
|
||||||
take () {
|
take () {
|
||||||
: 'Idempotently create directory recursively and cd into it'
|
: 'Idempotently create directory recursively and cd into it'
|
||||||
local out
|
local out
|
||||||
out=''$(set -o pipefail && mkdir -vp "''$@" | tail -1) || return
|
out=''$(set -o pipefail && mkdir -vp "''$@" | tail -1) || return
|
||||||
printf '%s\n' "''$out"
|
printf '%s\n' "''$out"
|
||||||
eval "out=''${out#"mkdir: created directory "}"
|
eval "out=''${out#"mkdir: created directory "}"
|
||||||
CDPATH= cd "''${out:-''${@: -1}}"
|
CDPATH= cd "''${out:-''${@: -1}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
cd () {
|
cd () {
|
||||||
: 'Run cd; on success in a terminal, show the 4 newest entries (with a count of hidden ones)'
|
: 'Run cd; on success in a terminal, show the 4 newest entries (with a count of hidden ones)'
|
||||||
|
|
||||||
builtin cd "''$@" || return
|
builtin cd "''$@" || return
|
||||||
|
|
@ -75,19 +71,19 @@ cd () {
|
||||||
mapfile -t lines < <(command ls --color=always --quoting-style=shell-escape -lArth)
|
mapfile -t lines < <(command ls --color=always --quoting-style=shell-escape -lArth)
|
||||||
if (( ''${#lines[@]} > 10 )); then
|
if (( ''${#lines[@]} > 10 )); then
|
||||||
printf '\033[7m... %d more entries ...\033[27m\n' "$(( ''${#lines[@]} - 10 ))";
|
printf '\033[7m... %d more entries ...\033[27m\n' "$(( ''${#lines[@]} - 10 ))";
|
||||||
printf '%s\n' "''${lines[@]: -9}"
|
printf '%s\n' "''${lines[@]: -4}"
|
||||||
else
|
else
|
||||||
printf '%s\n' "''${lines[@]}"
|
printf '%s\n' "''${lines[@]}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
drop_caches () {
|
drop_caches () {
|
||||||
: 'Drop pagecache, dentries and inodes'
|
: 'Drop pagecache, dentries and inodes'
|
||||||
: 'https://unix.stackexchange.com/a/87909'
|
: 'https://unix.stackexchange.com/a/87909'
|
||||||
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
|
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
respawn_shell () {
|
respawn_shell () {
|
||||||
: 'Intelligently respawn shell'
|
: 'Intelligently respawn shell'
|
||||||
: 'pure posix sh without forking'
|
: 'pure posix sh without forking'
|
||||||
if [ "''${BASH_VERSINFO-}" ] && command -v bash 1>/dev/null 2>&1; then
|
if [ "''${BASH_VERSINFO-}" ] && command -v bash 1>/dev/null 2>&1; then
|
||||||
|
|
@ -116,9 +112,9 @@ respawn_shell () {
|
||||||
printf 'You might want to manually run `exec [-l] "''$SHELL"`, however, `''$SHELL` might not be the shell you are currently running'
|
printf 'You might want to manually run `exec [-l] "''$SHELL"`, however, `''$SHELL` might not be the shell you are currently running'
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
export_bashrc () {
|
export_bashrc () {
|
||||||
CDPATH= command cd ~/.bashrc.d/ || return
|
CDPATH= command cd ~/.bashrc.d/ || return
|
||||||
: 'Not using an associative array because those are not sorted!'
|
: 'Not using an associative array because those are not sorted!'
|
||||||
declare -ar plugins=(*)
|
declare -ar plugins=(*)
|
||||||
|
|
@ -225,10 +221,10 @@ export_bashrc () {
|
||||||
read -p 'Self destruct (y/N)? ' choice || :
|
read -p 'Self destruct (y/N)? ' choice || :
|
||||||
[[ \''$choice = y ]] && { printf 'Trying to rm myself (%s)\\n' "\''${0@Q}"; rm -- "\''$0" && printf 'Success\\n' || printf 'Failed. Not trying further\\n'; }
|
[[ \''$choice = y ]] && { printf 'Trying to rm myself (%s)\\n' "\''${0@Q}"; rm -- "\''$0" && printf 'Success\\n' || printf 'Failed. Not trying further\\n'; }
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
#-#################################### binds #####################################
|
#-#################################### binds #####################################
|
||||||
bind '"\e\C-r": kill-region' \
|
bind '"\e\C-r": kill-region' \
|
||||||
'"\C-x\C-k": kill-whole-line' \
|
'"\C-x\C-k": kill-whole-line' \
|
||||||
'"\e\C-p": history-search-backward' \
|
'"\e\C-p": history-search-backward' \
|
||||||
'"\e\C-n": history-search-forward' \
|
'"\e\C-n": history-search-forward' \
|
||||||
|
|
@ -246,23 +242,23 @@ bind '"\e\C-r": kill-region' \
|
||||||
'set colored-completion-prefix on' \
|
'set colored-completion-prefix on' \
|
||||||
'set colored-stats on'
|
'set colored-stats on'
|
||||||
|
|
||||||
#-################################## autoclear ###################################
|
#-################################## autoclear ###################################
|
||||||
#-# TODO
|
#-# TODO
|
||||||
|
|
||||||
#-# prank () {
|
#-# prank () {
|
||||||
#-# line_up_until_cursor=''${READLINE_LINE::READLINE_POINT}
|
#-# line_up_until_cursor=''${READLINE_LINE::READLINE_POINT}
|
||||||
#-# line_after_cursor=''${READLINE_LINE:READLINE_POINT}
|
#-# line_after_cursor=''${READLINE_LINE:READLINE_POINT}
|
||||||
#-# if [[ ''$((RANDOM % 5)) -eq 0 ]]; then
|
#-# if [[ ''$((RANDOM % 5)) -eq 0 ]]; then
|
||||||
#-# READLINE_LINE="''$line_up_until_cursor''$line_after_cursor"
|
#-# READLINE_LINE="''$line_up_until_cursor''$line_after_cursor"
|
||||||
#-# #READLINE_LINE="''$line_up_until_cursor''${1^}''$line_after_cursor"
|
#-# #READLINE_LINE="''$line_up_until_cursor''${1^}''$line_after_cursor"
|
||||||
#-# READLINE_POINT=''$((READLINE_POINT+1))
|
#-# READLINE_POINT=''$((READLINE_POINT+1))
|
||||||
#-# else
|
#-# else
|
||||||
#-# READLINE_LINE="''$line_up_until_cursor''$1''$line_after_cursor"
|
#-# READLINE_LINE="''$line_up_until_cursor''$1''$line_after_cursor"
|
||||||
#-# READLINE_POINT=''$((READLINE_POINT+1))
|
#-# READLINE_POINT=''$((READLINE_POINT+1))
|
||||||
#-# fi
|
#-# fi
|
||||||
#-# }
|
#-# }
|
||||||
#-# bind -x '" ": prank " "'
|
#-# bind -x '" ": prank " "'
|
||||||
#-# bind -x '"a": prank "a"'
|
#-# bind -x '"a": prank "a"'
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue