2021-03-11 22:49:39 +00:00
|
|
|
#!/bin/bash
|
2021-02-20 22:59:54 +00:00
|
|
|
export ACP_BASHRC=1
|
|
|
|
|
|
|
|
if [ -f /etc/bashrc ]
|
|
|
|
then
|
|
|
|
. /etc/bashrc
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /usr/share/bash-completion/bash_completion ]
|
|
|
|
then
|
|
|
|
. /usr/share/bash-completion/bash_completion
|
|
|
|
elif [ -f /etc/bash_completion ]
|
|
|
|
then
|
|
|
|
. /etc/bash_completion
|
|
|
|
fi
|
|
|
|
|
|
|
|
_acp_add_path () {
|
|
|
|
if ! [[ "$PATH" =~ "$1:" ]] && test -d "$1"
|
|
|
|
then
|
|
|
|
PATH="$1:$PATH"
|
|
|
|
fi
|
|
|
|
export PATH
|
|
|
|
}
|
|
|
|
|
|
|
|
for dir in "$HOME/bin" \
|
|
|
|
"$HOME/.cargo/bin" \
|
|
|
|
"$HOME/opt/centos-git-common" \
|
|
|
|
/usr/local/sbin \
|
|
|
|
/usr/local/bin
|
|
|
|
do
|
|
|
|
_acp_add_path "$dir"
|
|
|
|
done
|
|
|
|
|
|
|
|
umask 0022
|
|
|
|
|
|
|
|
set -o emacs
|
|
|
|
set -o noclobber
|
|
|
|
|
|
|
|
# Locale and language.
|
|
|
|
## Clear the existing locale settings and set options I always want.
|
|
|
|
export TIME_STYLE=long-iso # Used by GNU 'ls'.
|
|
|
|
|
2021-02-21 14:46:29 +00:00
|
|
|
_acp_set_locale () {
|
2021-02-22 12:38:33 +00:00
|
|
|
local _acp_locale_selected=0
|
|
|
|
local _acp_entered_locale=
|
2021-02-21 14:46:29 +00:00
|
|
|
while [ $_acp_locale_selected -eq 0 ]
|
|
|
|
do
|
|
|
|
echo "Enter a locale, 'list', or leave blank to skip."
|
|
|
|
echo -n "[skip] "
|
|
|
|
read _acp_entered_locale
|
|
|
|
case "$_acp_entered_locale" in
|
|
|
|
list)
|
2021-02-22 12:38:33 +00:00
|
|
|
locale -a
|
2021-02-21 14:46:29 +00:00
|
|
|
;;
|
|
|
|
*)
|
2021-02-22 12:40:05 +00:00
|
|
|
if [ $(locale -a | grep "${_acp_entered_locale}" | wc -l) -eq 0 ]
|
2021-02-21 15:06:35 +00:00
|
|
|
then
|
|
|
|
echo "Invalid locale entered."
|
|
|
|
continue
|
|
|
|
fi
|
2021-02-21 15:40:42 +00:00
|
|
|
if [ -z "$_acp_entered_locale" ]
|
|
|
|
then
|
|
|
|
LANG=C.utf8
|
|
|
|
else
|
|
|
|
LANG="$_acp_entered_locale"
|
|
|
|
fi
|
2021-02-21 14:46:29 +00:00
|
|
|
_acp_locale_selected=1
|
2021-02-21 15:06:35 +00:00
|
|
|
;;
|
2021-02-21 14:46:29 +00:00
|
|
|
esac
|
2021-02-21 15:40:42 +00:00
|
|
|
LC_COLLATE="$LANG" # Alphabetic sorting.
|
|
|
|
LC_CTYPE="$LANG" # Interpretation of byte sequences.
|
|
|
|
LC_IDENTIFICATION="$LANG" # Locale metadata (GNU).
|
|
|
|
LC_MEASUREMENT="$LANG" # Units of measure -- metric/imperial (GNU).
|
|
|
|
LC_MESSAGES="$LANG" # Language that messages are displayed in.
|
|
|
|
LC_NAME="$LANG" # Salutations and titles (GNU).
|
|
|
|
LC_NUMERIC="$LANG" # Formatting for non-monetary numbers.
|
|
|
|
LC_TIME="$LANG" # Time format.
|
|
|
|
LC_ADDRESS="$LANG" # Postal address (GNU).
|
|
|
|
LC_MONETARY="$LANG" # Currency display.
|
|
|
|
LC_PAPER="$LANG" # Standard paper size -- A4 or Letter (GNU).
|
|
|
|
LC_TELEPHONE="$LANG" # Formats for telephone services (GNU).
|
|
|
|
if [ ! -z "$_acp_entered_locale" ]
|
|
|
|
then
|
|
|
|
rm -f "$HOME/.config/locale.conf"
|
|
|
|
locale > "$HOME/.config/locale.conf"
|
|
|
|
fi
|
2021-02-21 14:46:29 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -r "$HOME/.config/locale.conf" ]
|
2021-02-20 22:59:54 +00:00
|
|
|
then
|
2021-02-21 14:46:29 +00:00
|
|
|
. "$HOME/.config/locale.conf"
|
|
|
|
else
|
|
|
|
_acp_set_locale
|
2021-02-20 22:59:54 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
export LANG
|
2021-02-21 15:06:35 +00:00
|
|
|
export LC_COLLATE
|
|
|
|
export LC_CTYPE
|
|
|
|
export LC_IDENTIFICATION
|
|
|
|
export LC_MEASUREMENT
|
|
|
|
export LC_MESSAGES
|
|
|
|
export LC_NAME
|
|
|
|
export LC_NUMERIC
|
|
|
|
export LC_TIME
|
|
|
|
export LC_ADDRESS
|
|
|
|
export LC_MONETARY
|
|
|
|
export LC_PAPER
|
|
|
|
export LC_TELEPHONE
|
2021-02-20 22:59:54 +00:00
|
|
|
|
|
|
|
# Other exports.
|
|
|
|
export ANSIBLE_NOCOWS=1
|
|
|
|
export EDITOR=vi
|
|
|
|
export HISTCONTROL=ignorespace:ignoredups
|
2021-02-21 15:06:35 +00:00
|
|
|
export PAPERSIZE=a4
|
2021-02-20 22:59:54 +00:00
|
|
|
export POWERSHELL_TELEMETRY_OPTOUT=1
|
|
|
|
export PYTHONWARNINGS=ignore::UserWarning
|
|
|
|
|
2021-03-16 08:26:44 +00:00
|
|
|
if test -x /usr/bin/tty
|
|
|
|
then
|
2021-02-20 22:59:54 +00:00
|
|
|
export GPG_TTY=$(tty)
|
|
|
|
fi
|
|
|
|
|
|
|
|
shopt -s histappend
|
|
|
|
bind '"\e[1;5C": forward-word'
|
|
|
|
bind '"\e[1;5D": backward-word'
|
|
|
|
bind '"\e[A": history-search-backward'
|
|
|
|
bind '"\e[B": history-search-forward'
|
|
|
|
bind 'set bell-style none'
|
|
|
|
bind 'set completion-ignore-case on'
|
|
|
|
|
2021-03-16 08:26:44 +00:00
|
|
|
if test $(id -u) -eq 0
|
|
|
|
then
|
2021-02-21 15:20:49 +00:00
|
|
|
export PS1="\[\033[01;32m\]\u@\h\[\033[01;31m\]\#\[\033[00m\] "
|
2021-02-20 22:59:54 +00:00
|
|
|
else
|
2021-02-21 15:20:49 +00:00
|
|
|
export PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\]\$\[\033[00m\] "
|
2021-02-20 22:59:54 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
alias 7zencrypt="7z a -t7z -p -mhe"
|
|
|
|
alias alu="apt list --upgradable"
|
|
|
|
alias asdo="apt source --download-only"
|
|
|
|
alias aurmake="makepkg -irs"
|
|
|
|
alias btrdf="sudo btrfs filesystem usage"
|
|
|
|
alias cal="ncal -w"
|
|
|
|
alias df="df -x squashfs"
|
2021-03-16 08:26:44 +00:00
|
|
|
alias dquilt="quilt --quiltrc=\"${HOME}/.quiltrc-dpkg\""
|
2021-02-20 22:59:54 +00:00
|
|
|
alias ec="emacsclient -c"
|
|
|
|
alias en="emacsclient -nw"
|
|
|
|
alias f=fossil
|
|
|
|
alias ip="ip -c"
|
|
|
|
alias ll="ls -l --color=auto"
|
|
|
|
alias ls="ls -F --color=auto"
|
|
|
|
alias now="date +%Y%m%dT%H%M%S%z"
|
|
|
|
alias nowu="date -u +%Y%m%dT%H%M%SZ"
|
|
|
|
alias pacup="sudo pacman -Syu --needed"
|
|
|
|
alias streamenc="openssl aes-256-cbc -pbkdf2 -in - -out - -e"
|
|
|
|
alias streamdec="openssl aes-256-cbc -pbkdf2 -in - -out - -d"
|
|
|
|
alias ta="$HOME/opt/textadept/textadept"
|
|
|
|
alias wgr=wordgrinder
|
|
|
|
alias ytmp3="youtube-dl -q -x --audio-format=mp3"
|
|
|
|
alias zlu="zypper list-updates"
|
|
|
|
|
2021-03-16 08:26:44 +00:00
|
|
|
if [ -f /usr/share/bash-completion/completions/quilt ]
|
|
|
|
then
|
2021-03-16 08:30:56 +00:00
|
|
|
. /usr/share/bash-completion/completions/quilt
|
2021-03-16 08:26:44 +00:00
|
|
|
complete -F _quilt_completion -o filenames dquilt
|
|
|
|
fi
|
|
|
|
|
2021-02-20 22:59:54 +00:00
|
|
|
# Alias vi to vim if it is installed.
|
|
|
|
if [ -x /usr/bin/vim ]
|
|
|
|
then
|
|
|
|
alias vi=vim
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set up GOPATH.
|
|
|
|
export GOPATH="$HOME/data/go"
|
|
|
|
if [ -x "$HOME/opt/go/bin/go" ] || [ -x /usr/bin/go ] || [ -x /usr/local/bin/go ]
|
|
|
|
then
|
|
|
|
if [ ! -d "$GOPATH" ]
|
|
|
|
then
|
|
|
|
mkdir -p "$GOPATH/bin"
|
|
|
|
mkdir -p "$GOPATH/pkg"
|
|
|
|
mkdir -p "$GOPATH/src"
|
|
|
|
fi
|
|
|
|
if [ -x "$HOME/opt/go/bin/go" ]
|
|
|
|
then
|
|
|
|
export GOROOT="$HOME/opt/go"
|
|
|
|
_acp_add_path "$GOROOT/bin"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Useful aliases for Podman and Docker
|
|
|
|
alias prun="podman run --rm -it"
|
|
|
|
alias drun="sudo docker run --rm -it"
|
|
|
|
|
|
|
|
# Desktop files (used by desktop environments within both X11 and Wayland) are
|
|
|
|
# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for
|
|
|
|
# snappy applications' desktop files.
|
|
|
|
_snap_xdg_path=/var/lib/snapd/desktop
|
|
|
|
if [ -n "${XDG_DATA_DIRS##*${_snap_xdg_path}}" ] && [ -n "${XDG_DATA_DIRS##*${_snap_xdg_path}:*}" ]
|
|
|
|
then
|
|
|
|
export XDG_DATA_DIRS="${XDG_DATA_DIRS}:${_snap_xdg_path}"
|
|
|
|
fi
|
|
|
|
unset _snap_xdg_path
|
|
|
|
|
|
|
|
mkcd () {
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
then
|
|
|
|
echo "mkcd: incorrect arguments (one directory required)." >&2
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
mkdir -p "$1"
|
|
|
|
cd "$1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
termtitle () {
|
|
|
|
echo -en "\033]0;$1\007"
|
|
|
|
}
|
|
|
|
|
|
|
|
linapm () {
|
|
|
|
cat /sys/class/power_supply/BAT0/{status,capacity}
|
|
|
|
}
|
|
|
|
|
|
|
|
xa () {
|
|
|
|
out=$(xrandr --listactivemonitors | awk 'NR!=1{print " "$NF" "}')
|
|
|
|
for monitor in "$out"
|
|
|
|
do
|
|
|
|
m=$(echo "$monitor" | sed 's/ //g')
|
|
|
|
xrandr --output "$m" --auto
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
emacsro () {
|
|
|
|
emacs "$1" -f view-mode
|
|
|
|
}
|
|
|
|
|
|
|
|
tm () {
|
|
|
|
if tmux list-session 2>/dev/null 1>/dev/null
|
|
|
|
then
|
|
|
|
tmux -2 attach-session
|
|
|
|
else
|
|
|
|
tmux -2 new-session
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -x /usr/bin/yum ] && [ ! -x /usr/bin/dnf ]
|
|
|
|
then
|
|
|
|
alias dnf=yum
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$-" in
|
|
|
|
*i*)
|
|
|
|
# Shell is interactive
|
|
|
|
printf "\033[7m"; uname -sr; printf "\033[0m"
|
|
|
|
if [ -r /etc/os-release ]
|
|
|
|
then
|
|
|
|
echo " $(. /etc/os-release; echo $NAME $VERSION)"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if [ -S "$SSH_AUTH_SOCK" ] && [ -r "$HOME/.ssh/id_ed25519" ] && [ $(ssh-add -l | egrep "acp-(home|work) \(ED25519\)" | wc -l) = 0 ]
|
|
|
|
then
|
|
|
|
ssh-add "$HOME/.ssh/id_ed25519"
|
|
|
|
fi
|
|
|
|
|
2021-03-02 11:10:47 +00:00
|
|
|
if [ -r "$HOME/.bashrc.local" ]
|
2021-02-20 22:59:54 +00:00
|
|
|
then
|
2021-03-02 11:10:47 +00:00
|
|
|
. "$HOME/.bashrc.local"
|
2019-10-03 10:50:19 +00:00
|
|
|
fi
|