split bash config and modify bash prompt
This commit is contained in:
2
profiles/base/.bash/conf.d/00-base.bash
Normal file
2
profiles/base/.bash/conf.d/00-base.bash
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# If not running interactively, don't do anything
|
||||||
|
[[ $- != *i* ]] && return
|
||||||
@@ -47,7 +47,7 @@ if (( gentoo_color <= 0 )) || ( ! shopt -u direxpand 2>/dev/null ); then
|
|||||||
PS1='\u@\h \w \$ '
|
PS1='\u@\h \w \$ '
|
||||||
elif (( EUID == 0 )); then
|
elif (( EUID == 0 )); then
|
||||||
# If root, omit the username and print the hostname in red.
|
# If root, omit the username and print the hostname in red.
|
||||||
PS1='\[\e[01;31m\]\h\[\e[01;34m\] \w \$\[\e[00m\] '
|
PS1='\[\e[01;31m\]\h\[\e[01;34m\] \[\e[01;31m\]$(prompt_exit_code)\[\e[01;34m\]\w \$\[\e[00m\] '
|
||||||
else
|
else
|
||||||
# Otherwise, print the username and hostname in green.
|
# Otherwise, print the username and hostname in green.
|
||||||
PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \[\e[01;31m\]$(prompt_exit_code)\[\e[01;34m\]\w \$\[\e[00m\] '
|
PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \[\e[01;31m\]$(prompt_exit_code)\[\e[01;34m\]\w \$\[\e[00m\] '
|
||||||
5
profiles/base/.bash/conf.d/03-emacs.bash
Normal file
5
profiles/base/.bash/conf.d/03-emacs.bash
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# emacs specific stuff
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
[[ -n "${EAT_SHELL_INTEGRATION_DIR}" ]] && \
|
||||||
|
source "${EAT_SHELL_INTEGRATION_DIR}/bash"
|
||||||
27
profiles/base/.bash/conf.d/04-env.bash
Normal file
27
profiles/base/.bash/conf.d/04-env.bash
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Set environment 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"
|
||||||
|
|
||||||
|
# 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
|
||||||
6
profiles/base/.bash/conf.d/05-color-output.bash
Normal file
6
profiles/base/.bash/conf.d/05-color-output.bash
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
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\$"
|
||||||
74
profiles/base/.bash/conf.d/06-tool-integrations.bash
Normal file
74
profiles/base/.bash/conf.d/06-tool-integrations.bash
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
# 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")"
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
# 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
|
||||||
18
profiles/base/.bash/conf.d/07-aliases.bash
Normal file
18
profiles/base/.bash/conf.d/07-aliases.bash
Normal file
@@ -0,0 +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'
|
||||||
4
profiles/base/.bash/conf.d/08-functions.bash
Normal file
4
profiles/base/.bash/conf.d/08-functions.bash
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
take() {
|
||||||
|
mkdir -p "$1"
|
||||||
|
cd "$1" || exit 1
|
||||||
|
}
|
||||||
1
profiles/base/.bash/conf.d/09-keybindings.bash
Normal file
1
profiles/base/.bash/conf.d/09-keybindings.bash
Normal file
@@ -0,0 +1 @@
|
|||||||
|
bind '"\C-o":"ranger\n"'
|
||||||
@@ -2,147 +2,13 @@
|
|||||||
# ~/.bashrc
|
# ~/.bashrc
|
||||||
#
|
#
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
# load bash configuration
|
||||||
[[ $- != *i* ]] && return
|
readonly CONF_DIR="${HOME}/.bash/conf.d"
|
||||||
|
|
||||||
# scripts from gentoo
|
if [[ -d "${CONF_DIR}" ]]; then
|
||||||
|
for conf_file in "${CONF_DIR}"/*.bash; do
|
||||||
# shellcheck source=.bashrc.d/10-gentoo-color-r2.bash
|
[[ -r "${conf_file}" ]] || continue
|
||||||
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}"
|
|
||||||
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
|
# shellcheck source=/dev/null
|
||||||
[[ -f "/usr/libexec/mc/mc.sh" ]] && source "/usr/libexec/mc/mc.sh"
|
source "${conf_file}"
|
||||||
[[ -f "/usr/lib/mc/mc.sh" ]] && source "/usr/lib/mc/mc.sh"
|
done
|
||||||
|
|
||||||
# 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
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user