Run nixfmt (makes bash.nix ugly, but whatever
This commit is contained in:
parent
6248b242a3
commit
e8e13c992e
1 changed files with 259 additions and 259 deletions
|
|
@ -5,67 +5,67 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
enableCompletion = false;
|
enableCompletion = false;
|
||||||
initExtra = ''
|
initExtra = ''
|
||||||
if [[ ! -v BASH_COMPLETION_VERSINFO ]] &&
|
if [[ ! -v BASH_COMPLETION_VERSINFO ]] &&
|
||||||
[[ -f "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh" ]]; then
|
[[ -f "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh" ]]; then
|
||||||
source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
|
source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
|
||||||
fi
|
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'
|
||||||
# Warning
|
# Warning
|
||||||
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}}"
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_ls () {
|
safe_ls () {
|
||||||
command ls --color=always --quoting-style=shell-escape -lArth 2>/dev/null || \
|
command ls --color=always --quoting-style=shell-escape -lArth 2>/dev/null || \
|
||||||
command ls --color=always -q -lArth 2>/dev/null || \
|
command ls --color=always -q -lArth 2>/dev/null || \
|
||||||
command ls --color=always -lArth 2>/dev/null || \
|
command ls --color=always -lArth 2>/dev/null || \
|
||||||
|
|
@ -79,9 +79,9 @@ safe_ls () {
|
||||||
command ls -1 2>/dev/null || \
|
command ls -1 2>/dev/null || \
|
||||||
command printf '%q\n' * 2>/dev/null || \
|
command printf '%q\n' * 2>/dev/null || \
|
||||||
command printf '%s\n' * 2>/dev/null
|
command printf '%s\n' * 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -96,15 +96,15 @@ cd () {
|
||||||
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
|
||||||
|
|
@ -133,9 +133,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=(*)
|
||||||
|
|
@ -242,10 +242,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' \
|
||||||
|
|
@ -267,23 +267,23 @@ bind '"\e\C-r": kill-region' \
|
||||||
'set blink-matching-paren on' \
|
'set blink-matching-paren on' \
|
||||||
'set history-preserve-point on'
|
'set history-preserve-point 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