split bash config and modify bash prompt
This commit is contained in:
@@ -2,147 +2,13 @@
|
||||
# ~/.bashrc
|
||||
#
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
[[ $- != *i* ]] && return
|
||||
# load bash configuration
|
||||
readonly CONF_DIR="${HOME}/.bash/conf.d"
|
||||
|
||||
# scripts from gentoo
|
||||
|
||||
# shellcheck source=.bashrc.d/10-gentoo-color-r2.bash
|
||||
source "${HOME}/.bashrc.d/10-gentoo-color-r2.bash" # prompt
|
||||
# shellcheck source=.bashrc.d/10-gentoo-title-r3.bash
|
||||
source "${HOME}/.bashrc.d/10-gentoo-title-r3.bash"
|
||||
|
||||
# custom variables
|
||||
if command -v nvim &> /dev/null; then
|
||||
export EDITOR="nvim"
|
||||
else
|
||||
export EDITOR="vim"
|
||||
fi
|
||||
# export EDITOR="ec"
|
||||
export VISUAL="${EDITOR}"
|
||||
export SUDO_EDITOR="${EDITOR}"
|
||||
export VIRSH_DEFAULT_CONNECT_URI="qemu:///system"
|
||||
export BROWSER="chromium"
|
||||
export PAGER="less -R -F"
|
||||
export BAT_PAGER="${PAGER}"
|
||||
export MANPAGER="less -R --use-color -Dd+r -Du+b"
|
||||
[ -f "/usr/share/cowsay/cows" ] && export COWPATH="/usr/share/cowsay/cows"
|
||||
export CHROOT="${HOME}/arch_chroot"
|
||||
export AUR_REPO="whiteman808"
|
||||
export AURDEST="${HOME}/.cache/paru/clone"
|
||||
export AUR_PAGER="ranger"
|
||||
export GPGKEY="4A45503BBE575E3D4DAF28E27264AFFDC98D52BB"
|
||||
|
||||
# color output
|
||||
alias diff='diff --color=auto'
|
||||
alias grep='grep --color=auto'
|
||||
alias ip='ip -color=auto'
|
||||
alias ls='ls --color=auto'
|
||||
export MANROFFOPT="-P -c"
|
||||
export LESS="-R --use-color -Dd+r\$Du+b\$"
|
||||
|
||||
# better ls
|
||||
if type "eza" > /dev/null; then
|
||||
alias ll='eza -bghHlS'
|
||||
else
|
||||
alias ll='exa -bghHlS'
|
||||
fi
|
||||
|
||||
# bat (debian)
|
||||
if type "batcat" >/dev/null 2>&1; then
|
||||
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)
|
||||
# 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}
|
||||
}
|
||||
# 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
|
||||
|
||||
# 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'
|
||||
|
||||
take() {
|
||||
mkdir -p "$1"
|
||||
cd "$1" || exit 1
|
||||
}
|
||||
|
||||
# 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}"
|
||||
if [[ -d "${CONF_DIR}" ]]; then
|
||||
for conf_file in "${CONF_DIR}"/*.bash; do
|
||||
[[ -r "${conf_file}" ]] || continue
|
||||
# shellcheck source=/dev/null
|
||||
source "${conf_file}"
|
||||
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")"
|
||||
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
|
||||
bind '"\C-o":"ranger\n"'
|
||||
|
||||
# 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"
|
||||
|
||||
# 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)"
|
||||
export SSH_AUTH_SOCK
|
||||
fi
|
||||
|
||||
# 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 "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user