2019-10-03 10:50:19 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-04-09 08:59:41 +00:00
|
|
|
PATH="/usr/sbin:/sbin:/usr/bin:/bin"
|
|
|
|
for dir in $HOME/bin \
|
|
|
|
$HOME/.cargo/bin \
|
|
|
|
$HOME/.gem/ruby/2.6.0/bin \
|
|
|
|
/usr/X11R7/bin \
|
|
|
|
/usr/X11R6/bin \
|
|
|
|
/usr/local/sbin \
|
|
|
|
/usr/local/bin \
|
|
|
|
/usr/pkg/sbin \
|
|
|
|
/usr/pkg/bin \
|
|
|
|
/usr/games \
|
|
|
|
/usr/local/heirloom-doctools/bin \
|
|
|
|
/usr/pkg/heirloom-doctools/bin \
|
|
|
|
/var/lib/snapd/snap/bin \
|
|
|
|
/app/bin \
|
|
|
|
/snap/bin \
|
2020-05-18 14:18:38 +00:00
|
|
|
/usr/dt/bin \
|
2020-04-09 08:59:41 +00:00
|
|
|
; do
|
|
|
|
if [ -d "$dir" ]; then
|
|
|
|
PATH="$PATH:$dir"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
export PATH
|
|
|
|
|
|
|
|
MANPATH="/usr/share/man"
|
|
|
|
for dir in $HOME/.local/share/man \
|
|
|
|
/usr/X11R6/man \
|
|
|
|
/usr/X11R7/man \
|
|
|
|
/usr/local/man \
|
|
|
|
/usr/pkg/man \
|
|
|
|
/usr/local/share/man \
|
|
|
|
/usr/local/heirloom-doctools/man \
|
|
|
|
; do
|
|
|
|
if [ -d "$dir" ]; then
|
|
|
|
MANPATH="$MANPATH:$dir"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
export MANPATH
|
|
|
|
|
2019-10-03 10:50:19 +00:00
|
|
|
umask 0022
|
|
|
|
|
|
|
|
set -o emacs
|
|
|
|
set -o noclobber
|
|
|
|
|
|
|
|
# Locale and language.
|
2020-06-14 19:42:20 +00:00
|
|
|
## Clear the existing locale settings and set options I always want.
|
2020-06-22 21:57:15 +00:00
|
|
|
export LC_ALL=''
|
|
|
|
export TIME_STYLE="long-iso" # Used by GNU 'ls'.
|
|
|
|
## Set the default language.
|
|
|
|
export LANG="en_GB.UTF-8"
|
|
|
|
export LANGUAGE="en_GB:en"
|
2020-06-19 14:17:51 +00:00
|
|
|
## Use French if that is set as the system locale.
|
|
|
|
if [ -r /etc/default/locale ] && [ $(. /etc/default/locale; echo $LANG) = "fr_FR.UTF-8" ]; then
|
|
|
|
export LANG="fr_FR.UTF-8"
|
|
|
|
export LANGUAGE="fr_FR:fr"
|
2020-06-14 15:42:20 +00:00
|
|
|
fi
|
2020-06-22 21:57:15 +00:00
|
|
|
## Set the other language options to ${LANG}.
|
|
|
|
export LC_COLLATE="$LANG" # Alphabetic sorting.
|
|
|
|
export LC_CTYPE="$LANG" # Interpretation of byte sequences.
|
|
|
|
export LC_IDENTIFICATION="$LANG" # Locale metadata (GNU).
|
|
|
|
export LC_MEASUREMENT="$LANG" # Units of measure -- metric/imperial (GNU).
|
|
|
|
export LC_MESSAGES="$LANG" # Language that messages are displayed in.
|
|
|
|
export LC_NAME="$LANG" # Salutations and titles (GNU).
|
|
|
|
export LC_NUMERIC="$LANG" # Formatting for non-monetary numbers.
|
|
|
|
export LC_TIME="$LANG" # Time format.
|
|
|
|
## These should be set to the physical location.
|
|
|
|
export LC_ADDRESS="en_GB.UTF-8" # Postal address (GNU).
|
|
|
|
export LC_MONETARY="en_GB.UTF-8" # Currency display.
|
|
|
|
export LC_PAPER="en_GB.UTF-8" # Standard paper size -- A4 or Letter (GNU).
|
|
|
|
export LC_TELEPHONE="en_GB.UTF-8" # Formats for telephone services (GNU).
|
|
|
|
export PAPERSIZE="a4" # Default paper size (GhostScript).
|
2019-10-03 10:50:19 +00:00
|
|
|
|
|
|
|
# Other exports.
|
2020-01-15 17:22:36 +00:00
|
|
|
export ANSIBLE_NOCOWS=1
|
2020-11-21 17:30:48 +00:00
|
|
|
export CHROMIUM_FLAGS="--incognito"
|
2020-05-22 20:10:20 +00:00
|
|
|
export DEBEMAIL="anthony@acperkins.com"
|
|
|
|
export DEBFULLNAME="Anthony Perkins"
|
2019-10-03 10:50:19 +00:00
|
|
|
export EDITOR=vi
|
2020-03-05 14:58:48 +00:00
|
|
|
export POWERSHELL_TELEMETRY_OPTOUT=1
|
2019-10-03 10:50:19 +00:00
|
|
|
export PYTHONWARNINGS="ignore::UserWarning"
|
|
|
|
|
2019-11-21 12:22:44 +00:00
|
|
|
PS1="$ "
|
2020-04-09 08:59:41 +00:00
|
|
|
if test -z "${HOST}"; then
|
2020-04-07 14:46:49 +00:00
|
|
|
HOST="$(hostname 2>/dev/null || cat /etc/hostname)"
|
2019-11-21 12:22:05 +00:00
|
|
|
fi
|
2020-04-09 08:59:41 +00:00
|
|
|
if test $(id -u) -eq 0; then
|
2020-01-27 19:07:14 +00:00
|
|
|
export PS1="${HOST%%.*}# "
|
2019-11-21 12:44:38 +00:00
|
|
|
else
|
2020-01-27 19:07:14 +00:00
|
|
|
export PS1="${HOST%%.*}$ "
|
2019-11-21 12:44:38 +00:00
|
|
|
fi
|
2020-04-09 08:59:41 +00:00
|
|
|
if test -x /usr/bin/tty; then
|
|
|
|
export GPG_TTY=$(tty)
|
|
|
|
fi
|
2019-11-21 12:22:05 +00:00
|
|
|
|
2019-10-03 10:50:19 +00:00
|
|
|
if [ "$BASH" ]; then
|
|
|
|
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'
|
2020-06-22 21:15:24 +00:00
|
|
|
|
|
|
|
if test $(id -u) -eq 0; then
|
2020-10-27 13:30:01 +00:00
|
|
|
export PS1="\[\033[01;32m\]\h\[\033[01;31m\]\#\[\033[00m\] "
|
2020-06-22 21:15:24 +00:00
|
|
|
else
|
2020-10-27 13:30:01 +00:00
|
|
|
export PS1="\[\033[01;32m\]\h\[\033[01;34m\]\$\[\033[00m\] "
|
2020-06-22 21:15:24 +00:00
|
|
|
fi
|
2019-10-03 10:50:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$ZSH_VERSION" ]; then
|
|
|
|
# Command history.
|
2020-08-30 20:43:20 +00:00
|
|
|
autoload -Uz compinit && compinit
|
2019-10-03 10:50:19 +00:00
|
|
|
autoload -U history-search-end
|
|
|
|
zle -N history-beginning-search-backward-end history-search-end
|
|
|
|
zle -N history-beginning-search-forward-end history-search-end
|
|
|
|
bindkey "^[[A" history-beginning-search-backward-end
|
|
|
|
bindkey "^[[B" history-beginning-search-forward-end
|
|
|
|
bindkey "^[OA" history-beginning-search-backward-end
|
|
|
|
bindkey "^[OB" history-beginning-search-forward-end
|
|
|
|
|
|
|
|
bindkey "^[[1;5C" forward-word # Ctrl-Right
|
|
|
|
bindkey "^[[1;5D" backward-word # Ctrl-Left
|
|
|
|
bindkey "^[[3;5~" delete-char # Ctrl-Del
|
|
|
|
bindkey "^[[3~" delete-char # Del
|
2020-05-18 14:18:24 +00:00
|
|
|
bindkey "^[x" undefined-key # Alt-X
|
2020-11-11 22:27:45 +00:00
|
|
|
export HIST_IGNORE_SPACE=yes
|
2019-10-03 10:50:19 +00:00
|
|
|
export HISTFILE=$HOME/.zsh_history
|
|
|
|
export HISTSIZE=1000000
|
|
|
|
export SAVEHIST=1000000
|
|
|
|
setopt EXTENDED_HISTORY
|
|
|
|
setopt HIST_IGNORE_ALL_DUPS
|
|
|
|
setopt HIST_IGNORE_SPACE
|
|
|
|
setopt PROMPT_SUBST
|
|
|
|
setopt SHARE_HISTORY
|
2020-08-30 20:43:20 +00:00
|
|
|
setopt no_list_ambiguous
|
|
|
|
|
|
|
|
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
|
2020-06-22 21:15:24 +00:00
|
|
|
|
|
|
|
if test $(id -u) -eq 0; then
|
|
|
|
export PS1="%F{10}%m%F{9}#%f "
|
|
|
|
else
|
|
|
|
export PS1="%F{10}%m%F{12}$%f "
|
|
|
|
fi
|
2019-10-03 10:50:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
LSOPTIONS="-F"
|
|
|
|
if ls --color=auto /dev/null 2>/dev/null 1>/dev/null; then
|
|
|
|
LSOPTIONS="$LSOPTIONS --color=auto"
|
|
|
|
fi
|
|
|
|
if [ "$(uname -s)" = "FreeBSD" ]; then
|
|
|
|
LSOPTIONS="$LSOPTIONS -G"
|
|
|
|
fi
|
2019-11-12 17:44:33 +00:00
|
|
|
if [ "$(uname -s)" = "Linux" ]; then
|
|
|
|
alias df="df -x squashfs"
|
|
|
|
fi
|
2019-10-03 10:50:19 +00:00
|
|
|
|
2020-09-02 08:42:55 +00:00
|
|
|
alias 7zencrypt="7z a -t7z -p -mhe"
|
2019-10-03 10:50:19 +00:00
|
|
|
alias adoc="asciidoctor -a stylesheet=$HOME/.asciidoctor.css"
|
2020-05-22 08:02:29 +00:00
|
|
|
alias alu="apt list --upgradable"
|
2020-06-04 21:33:24 +00:00
|
|
|
alias asdo="apt source --download-only"
|
2020-04-18 19:50:47 +00:00
|
|
|
alias aurmake="makepkg -irs"
|
2020-11-02 23:15:12 +00:00
|
|
|
alias btrdf="sudo btrfs filesystem usage"
|
2019-10-03 10:50:19 +00:00
|
|
|
alias cal="ncal -w"
|
|
|
|
alias ec="emacsclient -c"
|
|
|
|
alias en="emacsclient -nw"
|
|
|
|
alias f="fossil"
|
2020-11-09 13:06:02 +00:00
|
|
|
alias ip="ip -c"
|
2019-10-03 10:50:19 +00:00
|
|
|
alias ll="/bin/ls -l"
|
|
|
|
alias ls="/bin/ls $LSOPTIONS"
|
|
|
|
alias now="date +%Y%m%dT%H%M%S%z"
|
|
|
|
alias nowu="date -u +%Y%m%dT%H%M%SZ"
|
2020-04-12 15:14:28 +00:00
|
|
|
alias pacup="sudo pacman -Syu --needed"
|
2020-10-27 14:29:33 +00:00
|
|
|
alias streamenc="openssl aes-256-cbc -pbkdf2 -in - -out - -e"
|
|
|
|
alias streamdec="openssl aes-256-cbc -pbkdf2 -in - -out - -d"
|
2019-10-03 10:50:19 +00:00
|
|
|
alias ta="$HOME/opt/textadept/textadept"
|
2020-01-05 21:51:18 +00:00
|
|
|
alias wgr="wordgrinder"
|
2019-10-03 10:50:19 +00:00
|
|
|
alias ytmp3="youtube-dl -q -x --audio-format=mp3"
|
2020-11-13 10:16:06 +00:00
|
|
|
alias zlu="zypper list-updates"
|
2019-10-03 10:50:19 +00:00
|
|
|
|
2019-10-18 14:37:12 +00:00
|
|
|
# QEMU aliases
|
|
|
|
alias qemu-486="qemu-system-i386 -machine isapc,accel=kvm -cpu 486 -m 16 -vga cirrus -soundhw sb16 -nic none" # -nic user,model=ne2k_isa
|
|
|
|
alias qemu-p1="qemu-system-i386 -machine pc,accel=tcg -cpu pentium -m 64 -vga cirrus -soundhw sb16 -nic none" # -nic user,model=ne2k_isa
|
|
|
|
alias qemu-p3="qemu-system-i386 -machine pc,accel=kvm -cpu pentium3 -m 256 -vga cirrus -usb -soundhw sb16 -nic none" # -nic user,model=rtl8139
|
|
|
|
alias qemu-core2="qemu-system-x86_64 -machine q35,accel=kvm -cpu core2duo -m 2048 -vga qxl -usb -soundhw hda -nic none" # -nic user,model=e1000
|
|
|
|
|
2019-10-03 10:50:19 +00:00
|
|
|
if [ ! -d "$HOME/.local/bin" ]; then
|
2020-04-09 08:59:41 +00:00
|
|
|
mkdir -p "$HOME/.local/bin"
|
2019-10-03 10:50:19 +00:00
|
|
|
fi
|
|
|
|
|
2020-04-06 09:47:35 +00:00
|
|
|
# Alias vi to vim if it is installed.
|
2019-11-28 16:14:47 +00:00
|
|
|
if [ -x /usr/bin/vim ] || [ -x /usr/local/bin/vim ] || [ -x /usr/pkg/bin/vim ]; then
|
2019-10-03 10:50:19 +00:00
|
|
|
alias vi="vim"
|
|
|
|
fi
|
|
|
|
|
2020-04-06 09:47:35 +00:00
|
|
|
# Set up GOPATH.
|
2019-10-03 10:50:19 +00:00
|
|
|
export GOPATH="$HOME/data/go"
|
2020-10-07 20:21:59 +00:00
|
|
|
if [ -x $HOME/opt/go/bin/go ] || [ -x /usr/bin/go ] || [ -x /usr/local/bin/go ]; then
|
2019-10-03 10:50:19 +00:00
|
|
|
if [ ! -d "$GOPATH" ]; then
|
2020-04-09 08:59:41 +00:00
|
|
|
mkdir -p "$GOPATH/bin"
|
|
|
|
mkdir -p "$GOPATH/pkg"
|
|
|
|
mkdir -p "$GOPATH/src"
|
2019-10-03 10:50:19 +00:00
|
|
|
fi
|
2020-10-07 20:21:59 +00:00
|
|
|
if [ -x $HOME/opt/go/bin/go ]; then
|
|
|
|
export GOROOT="$HOME/opt/go"
|
|
|
|
export PATH="$PATH:$GOROOT/bin"
|
|
|
|
fi
|
2020-04-09 08:59:41 +00:00
|
|
|
export PATH="$PATH:$GOPATH"
|
2019-10-03 10:50:19 +00:00
|
|
|
fi
|
|
|
|
|
2020-04-06 09:47:35 +00:00
|
|
|
# Use a manually-installed ansible if available.
|
|
|
|
if [ -x "$HOME/opt/ansible/bin/ansible" ]; then
|
|
|
|
alias ansible="$HOME/opt/ansible/bin/ansible"
|
|
|
|
alias ansible-playbook="$HOME/opt/ansible/bin/ansible-playbook"
|
|
|
|
fi
|
|
|
|
|
2019-10-03 10:50:19 +00:00
|
|
|
# Useful aliases for Podman and Docker
|
2020-05-20 15:48:14 +00:00
|
|
|
alias prun="podman run --rm -it"
|
2020-11-09 13:05:50 +00:00
|
|
|
alias prunx="podman run --security-opt label=disable -v /tmp/.X11-unix/:/tmp/.X11-unix/ -e DISPLAY=\"unix\$DISPLAY\" -v /run/user/$(id -u)/:/run/user/$(id -u)/ -e XDG_RUNTIME_DIR=/run/user/$(id -u) -e PULSE_SERVER=/run/user/$(id -u)/pulse/native --ipc host"
|
2020-05-20 15:48:14 +00:00
|
|
|
alias drun="sudo docker run --rm -it"
|
|
|
|
alias drunx="sudo docker run -v /tmp/.X11-unix:/tmp/.X11-unix:ro -e DISPLAY=\"unix\$DISPLAY\""
|
2019-10-03 10:50:19 +00:00
|
|
|
|
2020-11-21 17:37:58 +00:00
|
|
|
# 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
|
|
|
|
|
2019-10-03 10:50:19 +00:00
|
|
|
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}
|
|
|
|
}
|
|
|
|
|
|
|
|
cman () {
|
|
|
|
# md: start bold
|
|
|
|
# us: start underline
|
|
|
|
# ue: end underline
|
|
|
|
# me: end bold, blink, and underline
|
|
|
|
env MANPAGER=less \
|
|
|
|
LESS_TERMCAP_md=$'\e[1;36m' \
|
|
|
|
LESS_TERMCAP_me=$'\e[0m' \
|
|
|
|
LESS_TERMCAP_us=$'\e[4;32m' \
|
|
|
|
LESS_TERMCAP_ue=$'\e[0m' \
|
|
|
|
/usr/bin/man "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-12-16 15:15:49 +00:00
|
|
|
lastreboots () {
|
|
|
|
journalctl | grep -A 1 -- '-- Reboot --' | grep -v '^--' | awk '{print $1, $2, $3}'
|
|
|
|
}
|
|
|
|
|
2020-01-27 18:57:58 +00:00
|
|
|
emacsro () {
|
2020-01-25 17:01:01 +00:00
|
|
|
emacs $1 -f view-mode
|
|
|
|
}
|
|
|
|
|
2020-02-05 17:35:32 +00:00
|
|
|
tm () {
|
|
|
|
if tmux list-session 2>/dev/null 1>/dev/null; then
|
|
|
|
tmux -2 attach-session
|
|
|
|
else
|
|
|
|
tmux -2 new-session
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-06-22 21:15:00 +00:00
|
|
|
qemuquick () {
|
2020-03-09 21:43:02 +00:00
|
|
|
qemu-system-x86_64 -nodefaults -readconfig $1
|
|
|
|
}
|
|
|
|
|
2019-10-03 10:50:19 +00:00
|
|
|
if [ -x /usr/bin/yum ] && [ ! -x /usr/bin/dnf ]; then
|
|
|
|
alias dnf='yum'
|
|
|
|
fi
|
|
|
|
|
2020-06-14 19:42:41 +00:00
|
|
|
if test -n "$DISPLAY" && test -x /usr/bin/emacsclient; then
|
|
|
|
export EDITOR="/usr/bin/emacsclient -c -a vi"
|
2020-02-12 12:16:33 +00:00
|
|
|
fi
|
|
|
|
|
2019-10-03 10:50:19 +00:00
|
|
|
if [ -x /usr/bin/svnlite ] && [ ! -x /usr/local/bin/svn ]; then
|
|
|
|
alias svn='svnlite'
|
|
|
|
alias svnadmin='svnliteadmin'
|
|
|
|
alias svndumpfilter='svnlitedumpfilter'
|
|
|
|
alias svnlook='svnlitelook'
|
|
|
|
alias svnmucc='svnlitemucc'
|
|
|
|
alias svnrdump='svnliterdump'
|
|
|
|
alias svnserve='svnliteserve'
|
|
|
|
alias svnsync='svnlitesync'
|
|
|
|
alias svnversion='svnliteversion'
|
|
|
|
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 $PRETTY_NAME)"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-02-06 11:20:47 +00:00
|
|
|
if test -S "$SSH_AUTH_SOCK" && test -r "$HOME/.ssh/id_rsa" && [ $(ssh-add -l | grep "$HOME/.ssh/id_rsa" | wc -l) = 0 ]; then
|
|
|
|
ssh-add "$HOME/.ssh/id_rsa"
|
2020-02-05 15:38:15 +00:00
|
|
|
fi
|
|
|
|
|
2020-04-07 14:46:49 +00:00
|
|
|
if [ -r $HOME/.shrc.$(hostname -s 2>/dev/null || cat /etc/hostname) ]; then
|
|
|
|
. $HOME/.shrc.$(hostname -s 2>/dev/null || cat /etc/hostname)
|
2019-10-03 10:50:19 +00:00
|
|
|
fi
|