[profiles/base] modify bash config

This commit is contained in:
2026-02-21 06:02:21 +01:00
parent abf96107ab
commit 4192eb836c
6 changed files with 82 additions and 42 deletions

View File

@@ -1,54 +1,59 @@
# better ls
if command -v eza >/dev/null 2>&1; then
alias ll="eza -bghHlS"
alias ll="eza -bghHlS"
else
alias ll="exa -bghHlS"
alias ll="exa -bghHlS"
fi
# bat (debian)
if command -v batcat >/dev/null 2>&1; then
alias bat=batcat
alias bat=batcat
fi
# HSTR configuration - add this to ~/.bashrc
alias hh=hstr # hh to be alias for hstr
export HSTR_CONFIG=hicolor # get more colors
shopt -s histappend # append new history items to .bash_history
export HISTCONTROL=ignorespace # leading space hides commands from history
export HISTFILESIZE=10000 # increase history file size (default is 500)
export HISTSIZE=${HISTFILESIZE} # increase history size (default is 500)
alias hh="hstr" # hh to be alias for hstr
export HSTR_CONFIG="hicolor" # get more colors
shopt -s histappend # append new history items to .bash_history
export HISTCONTROL="ignorespace" # leading space hides commands from history
export HISTFILESIZE="10000" # increase history file size (default is 500)
export HISTSIZE="${HISTFILESIZE}" # increase history size (default is 500)
# ensure synchronization between bash memory and history file
export PROMPT_COMMAND=("history -a; history -n;" "${PROMPT_COMMAND[@]}")
function hstrnotiocsti {
{ READLINE_LINE="$( { </dev/tty hstr -- "${READLINE_LINE}"; } 2>&1 1>&3 3>&- )"; } 3>&1;
READLINE_POINT=${#READLINE_LINE}
{ READLINE_LINE="$({ </dev/tty hstr -- "${READLINE_LINE}"; } \
2>&1 1>&3 3>&-)"; } 3>&1
READLINE_POINT="${#READLINE_LINE}"
}
# if this is interactive shell, then bind hstr to Ctrl-r (for Vi mode check doc)
if [[ $- =~ .*i.* ]]; then bind -x '"\C-r": "hstrnotiocsti"'; fi
export HSTR_TIOCSTI=n
if [[ $- =~ .*i.* ]]; then
bind -x '"\C-r": "hstrnotiocsti"'
fi
export HSTR_TIOCSTI="n"
# ranger
ranger_cd() {
temp_file=$(mktemp -t "ranger_cd.XXXXXXXXXX")
ranger --choosedir="${temp_file}" -- "${@:-${PWD}}"
if chosen_dir="$(cat -- "${temp_file}")" && [[ "${chosen_dir}" ]] && [[ "${chosen_dir}" != "${PWD}" ]]; then
cd -- "${chosen_dir}" || exit 1
fi
rm -f -- "${temp_file}"
temp_file="$(mktemp -t "ranger_cd.XXXXXXXXXX")"
ranger --choosedir="${temp_file}" -- "${@:-${PWD}}"
if chosen_dir="$(cat -- "${temp_file}")" &&
[[ -n "${chosen_dir}" ]] &&
[[ "${chosen_dir}" != "${PWD}" ]]; then
cd -- "${chosen_dir}" || exit 1
fi
rm -f -- "${temp_file}"
}
alias ranger=ranger_cd
alias ranger="ranger_cd"
# mc
# shellcheck source=/dev/null
[[ -f /usr/libexec/mc/mc.sh ]] && . /usr/libexec/mc/mc.sh
[[ -f /usr/lib/mc/mc.sh ]] && . /usr/lib/mc/mc.sh
[[ -f "/usr/libexec/mc/mc.sh" ]] && . "/usr/libexec/mc/mc.sh"
[[ -f "/usr/lib/mc/mc.sh" ]] && . "/usr/lib/mc/mc.sh"
# inside tmux, we don't know if Sway got restarted
if [[ -v TMUX ]]; then
swaymsg() {
SWAYSOCK=${XDG_RUNTIME_DIR}/sway-ipc.${UID}.$(pgrep -x sway).sock
export SWAYSOCK
command swaymsg "$@"
}
swaymsg() {
SWAYSOCK="${XDG_RUNTIME_DIR}/sway-ipc.${UID}.$(pgrep -x sway).sock"
export SWAYSOCK
command swaymsg "$@"
}
fi