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;
|
||||
enableCompletion = false;
|
||||
initExtra = ''
|
||||
if [[ ! -v BASH_COMPLETION_VERSINFO ]] &&
|
||||
if [[ ! -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
|
||||
fi
|
||||
|
||||
[ "$DISPLAY" ] && xset r rate 300 60
|
||||
[ "$DISPLAY" ] && xset r rate 300 60
|
||||
|
||||
#-##################### user specific aliases and functions ######################
|
||||
if [ -d ~/.bashrc.d ]; then
|
||||
#-##################### user specific aliases and functions ######################
|
||||
if [ -d ~/.bashrc.d ]; then
|
||||
for rc in ~/.bashrc.d/*; do
|
||||
bn=''${rc##*/}
|
||||
if [ -f "''$rc" ] && [ -r "''$rc" ] && [ ! "''${bn::1}" = '.' ]; then
|
||||
\. "''$rc"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
unset rc bn
|
||||
fi
|
||||
unset rc bn
|
||||
|
||||
#-########################### shell settings & options ###########################
|
||||
set -E
|
||||
set -o pipefail
|
||||
#-########################### shell settings & options ###########################
|
||||
set -E
|
||||
set -o pipefail
|
||||
|
||||
shopt -s nullglob dotglob globstar extglob
|
||||
shopt -s autocd cdable_vars cdspell
|
||||
shopt -s checkwinsize
|
||||
shopt -s lastpipe
|
||||
shopt -s inherit_errexit
|
||||
shopt -s no_empty_cmd_completion
|
||||
shopt -s histreedit
|
||||
shopt -s lithist
|
||||
shopt -u histverify
|
||||
_have bash_abbr && shopt -u expand_aliases
|
||||
shopt -s nullglob dotglob globstar extglob
|
||||
shopt -s autocd cdable_vars cdspell
|
||||
shopt -s checkwinsize
|
||||
shopt -s lastpipe
|
||||
shopt -s inherit_errexit
|
||||
shopt -s no_empty_cmd_completion
|
||||
shopt -s histreedit
|
||||
shopt -s lithist
|
||||
shopt -u histverify
|
||||
_have bash_abbr && shopt -u expand_aliases
|
||||
|
||||
#-############################### shell variables ################################
|
||||
FIGNORE='.o'
|
||||
# Warning
|
||||
HISTCONTROL=ignoreboth:erasedups
|
||||
HISTTIMEFORMAT='%y-%m-%d %H:%M:%S '
|
||||
HISTSIZE=-1
|
||||
HISTFILESIZE=-1
|
||||
HISTFILE=''$HOME/.''${USER:-default}_bash_history
|
||||
#-############################### shell variables ################################
|
||||
FIGNORE='.o'
|
||||
# Warning
|
||||
HISTCONTROL=ignoreboth:erasedups
|
||||
HISTTIMEFORMAT='%y-%m-%d %H:%M:%S '
|
||||
HISTSIZE=-1
|
||||
HISTFILESIZE=-1
|
||||
HISTFILE=''$HOME/.''${USER:-default}_bash_history
|
||||
|
||||
#-############################ environment variables #############################
|
||||
export PYTHON_BASIC_REPL=1 # I'm good at readline so I'm gonna use readline whereever possible!
|
||||
export LESS='-SRFX'
|
||||
export PAGER='less' GIT_PAGER='less' MANPAGER='less' SYSTEMD_PAGER='less'
|
||||
export BAT_PAGER='''
|
||||
export EDITOR='vim' VISUAL='vim' FCEDIT='vim' SYSTEMD_EDITOR='vim'
|
||||
export PATH
|
||||
#-############################ environment variables #############################
|
||||
export PYTHON_BASIC_REPL=1 # I'm good at readline so I'm gonna use readline whereever possible!
|
||||
export LESS='-SRFX'
|
||||
export PAGER='less' GIT_PAGER='less' MANPAGER='less' SYSTEMD_PAGER='less'
|
||||
export BAT_PAGER='''
|
||||
export EDITOR='vim' VISUAL='vim' FCEDIT='vim' SYSTEMD_EDITOR='vim'
|
||||
export PATH
|
||||
|
||||
#-########################## generally useful functions ##########################
|
||||
take () {
|
||||
#-########################## generally useful functions ##########################
|
||||
take () {
|
||||
: 'Idempotently create directory recursively and cd into it'
|
||||
local out
|
||||
out=''$(set -o pipefail && mkdir -vp "''$@" | tail -1) || return
|
||||
printf '%s\n' "''$out"
|
||||
eval "out=''${out#"mkdir: created directory "}"
|
||||
CDPATH= cd "''${out:-''${@: -1}}"
|
||||
}
|
||||
}
|
||||
|
||||
safe_ls () {
|
||||
safe_ls () {
|
||||
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 -lArth 2>/dev/null || \
|
||||
|
|
@ -79,9 +79,9 @@ safe_ls () {
|
|||
command ls -1 2>/dev/null || \
|
||||
command printf '%q\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)'
|
||||
|
||||
builtin cd "''$@" || return
|
||||
|
|
@ -96,15 +96,15 @@ cd () {
|
|||
else
|
||||
printf '%s\n' "''${lines[@]}"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
drop_caches () {
|
||||
drop_caches () {
|
||||
: 'Drop pagecache, dentries and inodes'
|
||||
: 'https://unix.stackexchange.com/a/87909'
|
||||
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
|
||||
}
|
||||
}
|
||||
|
||||
respawn_shell () {
|
||||
respawn_shell () {
|
||||
: 'Intelligently respawn shell'
|
||||
: 'pure posix sh without forking'
|
||||
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'
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
export_bashrc () {
|
||||
export_bashrc () {
|
||||
CDPATH= command cd ~/.bashrc.d/ || return
|
||||
: 'Not using an associative array because those are not sorted!'
|
||||
declare -ar plugins=(*)
|
||||
|
|
@ -242,10 +242,10 @@ export_bashrc () {
|
|||
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'; }
|
||||
EOF
|
||||
}
|
||||
}
|
||||
|
||||
#-#################################### binds #####################################
|
||||
bind '"\e\C-r": kill-region' \
|
||||
#-#################################### binds #####################################
|
||||
bind '"\e\C-r": kill-region' \
|
||||
'"\C-x\C-k": kill-whole-line' \
|
||||
'"\e\C-p": history-search-backward' \
|
||||
'"\e\C-n": history-search-forward' \
|
||||
|
|
@ -267,23 +267,23 @@ bind '"\e\C-r": kill-region' \
|
|||
'set blink-matching-paren on' \
|
||||
'set history-preserve-point on'
|
||||
|
||||
#-################################## autoclear ###################################
|
||||
#-# TODO
|
||||
#-################################## autoclear ###################################
|
||||
#-# TODO
|
||||
|
||||
#-# prank () {
|
||||
#-# line_up_until_cursor=''${READLINE_LINE::READLINE_POINT}
|
||||
#-# line_after_cursor=''${READLINE_LINE:READLINE_POINT}
|
||||
#-# if [[ ''$((RANDOM % 5)) -eq 0 ]]; then
|
||||
#-# READLINE_LINE="''$line_up_until_cursor''$line_after_cursor"
|
||||
#-# #READLINE_LINE="''$line_up_until_cursor''${1^}''$line_after_cursor"
|
||||
#-# READLINE_POINT=''$((READLINE_POINT+1))
|
||||
#-# else
|
||||
#-# READLINE_LINE="''$line_up_until_cursor''$1''$line_after_cursor"
|
||||
#-# READLINE_POINT=''$((READLINE_POINT+1))
|
||||
#-# fi
|
||||
#-# }
|
||||
#-# bind -x '" ": prank " "'
|
||||
#-# bind -x '"a": prank "a"'
|
||||
#-# prank () {
|
||||
#-# line_up_until_cursor=''${READLINE_LINE::READLINE_POINT}
|
||||
#-# line_after_cursor=''${READLINE_LINE:READLINE_POINT}
|
||||
#-# if [[ ''$((RANDOM % 5)) -eq 0 ]]; then
|
||||
#-# READLINE_LINE="''$line_up_until_cursor''$line_after_cursor"
|
||||
#-# #READLINE_LINE="''$line_up_until_cursor''${1^}''$line_after_cursor"
|
||||
#-# READLINE_POINT=''$((READLINE_POINT+1))
|
||||
#-# else
|
||||
#-# READLINE_LINE="''$line_up_until_cursor''$1''$line_after_cursor"
|
||||
#-# READLINE_POINT=''$((READLINE_POINT+1))
|
||||
#-# fi
|
||||
#-# }
|
||||
#-# bind -x '" ": prank " "'
|
||||
#-# bind -x '"a": prank "a"'
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue