refactor code and add fallback prompt to zsh

This commit is contained in:
2026-02-13 10:19:45 +01:00
parent 1cdc70eb70
commit 25a4a6076c
19 changed files with 150 additions and 189 deletions

View File

@@ -1,5 +1,4 @@
# emacs specific stuff
# shellcheck source=/dev/null
[[ -n "${EAT_SHELL_INTEGRATION_DIR}" ]] && \
source "${EAT_SHELL_INTEGRATION_DIR}/bash"
[[ ${EAT_SHELL_INTEGRATION_DIR} ]] && . "${EAT_SHELL_INTEGRATION_DIR}/bash"

View File

@@ -1,5 +1,5 @@
# Set environment variables
if command -v nvim &> /dev/null; then
if command -v nvim >/dev/null 2>&1; then
export EDITOR="nvim"
else
export EDITOR="vim"
@@ -21,7 +21,7 @@ export GPGKEY="4A45503BBE575E3D4DAF28E27264AFFDC98D52BB"
# gpg-agent
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket 2>/dev/null)"
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne "$$" ]]; then
SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket 2>/dev/null)
export SSH_AUTH_SOCK
fi

View File

@@ -1,13 +1,13 @@
# better ls
if type "eza" > /dev/null; then
alias ll='eza -bghHlS'
if command -v eza >/dev/null 2>&1; then
alias ll="eza -bghHlS"
else
alias ll='exa -bghHlS'
alias ll="exa -bghHlS"
fi
# bat (debian)
if type "batcat" >/dev/null 2>&1; then
alias bat='batcat'
if command -v batcat >/dev/null 2>&1; then
alias bat=batcat
fi
# HSTR configuration - add this to ~/.bashrc
@@ -18,7 +18,7 @@ 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[@]}" )
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}
@@ -27,31 +27,11 @@ function hstrnotiocsti {
if [[ $- =~ .*i.* ]]; then bind -x '"\C-r": "hstrnotiocsti"'; fi
export HSTR_TIOCSTI=n
# lf
lfwrapper() {
command lf "$@"
# cleanup
awk '$1 == "archivemount" { print $2 }' /etc/mtab | while read -r mntdir; do
sanitized_input="$(printf "${mntdir}")" # /etc/mtab uses octal representation of spaces (possible other symbols too), printf would convert octal representation, so that it can be used in the umount & rmdir commands.
umount "${sanitized_input}"
rmdir "${sanitized_input}"
done
}
lfcd() {
dir="$(lfwrapper -print-last-dir "$@")"
while ! cd "${dir}" 2>/dev/null; do
dir="$(dirname -- "${dir}")"
done
}
alias lf=lfcd
# ranger
ranger_cd() {
temp_file="$(mktemp -t "ranger_cd.XXXXXXXXXX")"
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
if chosen_dir="$(cat -- "${temp_file}")" && [[ "${chosen_dir}" ]] && [[ "${chosen_dir}" != "${PWD}" ]]; then
cd -- "${chosen_dir}" || exit 1
fi
rm -f -- "${temp_file}"
@@ -61,8 +41,8 @@ alias ranger=ranger_cd
# mc
# shellcheck source=/dev/null
[[ -f "/usr/libexec/mc/mc.sh" ]] && source "/usr/libexec/mc/mc.sh"
[[ -f "/usr/lib/mc/mc.sh" ]] && source "/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

View File

@@ -1,18 +1,18 @@
# useful commands
alias ncmpcpp='ncmpcpp -b ~/.config/ncmpcpp/bindings'
alias tb='nc termbin.com 9999'
alias mux='tmuxinator'
alias tm='tmuxinator start misc'
alias tq='tmuxinator start quake'
alias sudo='sudo '
alias rsync_copy='rsync -aAXUHvh --partial-dir=.rsync-partial --progress'
alias rsync_copy_ssh='rsync_copy -e ssh'
alias rsync_backup='rsync_copy --numeric-ids --delete --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}'
alias rsync_backup_ssh='rsync_backup -e ssh'
alias rsync_restore='rsync_copy --numeric-ids --delete --exclude="lost+found"'
alias rsync_restore_ssh='rsync_restore -e ssh'
alias glog='git log --oneline'
alias emerge_world='emerge --ask --verbose --deep --newuse --update @world'
alias sync_repo='rsync_copy_ssh --delete ~/arch_paczuchy/* vps.paraboletancza.org:/srv/http/arch.paraboletancza.org'
alias aur_sync='aur sync --sign --chroot'
alias aur_build='aur build --sign --chroot'
alias ncmpcpp="ncmpcpp -b ~/.config/ncmpcpp/bindings"
alias tb="nc termbin.com 9999"
alias mux="tmuxinator"
alias tm="tmuxinator start misc"
alias tq="tmuxinator start quake"
alias sudo="sudo "
alias rsync_copy="rsync -aAXUHvh --partial-dir=.rsync-partial --progress"
alias rsync_copy_ssh="rsync_copy -e ssh"
alias rsync_backup="rsync_copy --numeric-ids --delete --exclude={'/dev/*','/proc/*','/sys/*','/tmp/*','/run/*','/mnt/*','/media/*','/lost+found'}"
alias rsync_backup_ssh="rsync_backup -e ssh"
alias rsync_restore="rsync_copy --numeric-ids --delete --exclude='lost+found'"
alias rsync_restore_ssh="rsync_restore -e ssh"
alias glog="git log --oneline"
alias emerge_world="emerge --ask --verbose --deep --newuse --update @world"
alias sync_repo="rsync_copy_ssh --delete ~/arch_paczuchy/* vps.paraboletancza.org:/srv/http/arch.paraboletancza.org"
alias aur_sync="aur sync --sign --chroot"
alias aur_build="aur build --sign --chroot"