Replace tabs with four spaces

This commit is contained in:
Anthony Rose 2022-11-28 22:45:54 +00:00
parent a300cdbc90
commit 2b38e4941c
2 changed files with 226 additions and 226 deletions

View file

@ -31,9 +31,9 @@ if [ ! -d "$HOME/.local/bin" ] ; then install -d -m 0700 "$HOME/.local/bin" ; fi
if [ -d /var/acp ] && ! [ -L /var/acp ] if [ -d /var/acp ] && ! [ -L /var/acp ]
then then
export ACP=/var/acp export ACP=/var/acp
else else
export ACP="$HOME/data" export ACP="$HOME/data"
fi fi
# Locale and language. # Locale and language.
@ -41,11 +41,11 @@ fi
export TZ=Europe/London # Can override this elsewhere if needed. export TZ=Europe/London # Can override this elsewhere if needed.
if ! [ -f "$XDG_CONFIG_HOME/locale.conf" ] && [ -x /usr/bin/locale ] if ! [ -f "$XDG_CONFIG_HOME/locale.conf" ] && [ -x /usr/bin/locale ]
then then
LANG="en_GB.UTF-8" /usr/bin/locale > "$XDG_CONFIG_HOME/locale.conf" LANG="en_GB.UTF-8" /usr/bin/locale > "$XDG_CONFIG_HOME/locale.conf"
fi fi
if [ -r "$XDG_CONFIG_HOME/locale.conf" ] if [ -r "$XDG_CONFIG_HOME/locale.conf" ]
then then
. "$XDG_CONFIG_HOME/locale.conf" . "$XDG_CONFIG_HOME/locale.conf"
fi fi
# Desktop files (used by desktop environments within both X11 and Wayland) are # Desktop files (used by desktop environments within both X11 and Wayland) are
@ -54,96 +54,96 @@ fi
_snap_xdg_path=/var/lib/snapd/desktop _snap_xdg_path=/var/lib/snapd/desktop
if [ -x /usr/lib/snapd/snapd ] && [ -n "${XDG_DATA_DIRS##*${_snap_xdg_path}}" ] && [ -n "${XDG_DATA_DIRS##*${_snap_xdg_path}:*}" ] if [ -x /usr/lib/snapd/snapd ] && [ -n "${XDG_DATA_DIRS##*${_snap_xdg_path}}" ] && [ -n "${XDG_DATA_DIRS##*${_snap_xdg_path}:*}" ]
then then
XDG_DATA_DIRS="${XDG_DATA_DIRS}:${_snap_xdg_path}" XDG_DATA_DIRS="${XDG_DATA_DIRS}:${_snap_xdg_path}"
fi fi
unset _snap_xdg_path unset _snap_xdg_path
# Bash-specific settings that will not work in other Bourne-compatible shells. # Bash-specific settings that will not work in other Bourne-compatible shells.
if [ -n "$BASH_VERSION" ] if [ -n "$BASH_VERSION" ]
then then
set -o emacs set -o emacs
set -o noclobber set -o noclobber
shopt -s histappend shopt -s histappend
bind '"\e[1;5C": forward-word' bind '"\e[1;5C": forward-word'
bind '"\e[1;5D": backward-word' bind '"\e[1;5D": backward-word'
bind '"\e[A": history-search-backward' bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward' bind '"\e[B": history-search-forward'
bind 'set bell-style none' bind 'set bell-style none'
bind 'set completion-ignore-case on' bind 'set completion-ignore-case on'
bind 'set enable-bracketed-paste off' bind 'set enable-bracketed-paste off'
export BASH_ENV="$HOME/.bashrc" export BASH_ENV="$HOME/.bashrc"
if [ "$container" = flatpak ] if [ "$container" = flatpak ]
then then
_acp_ps1_prefix="*" _acp_ps1_prefix="*"
fi fi
PS1="\[\033[01m\]${_acp_ps1_prefix}\u@\h\\$\[\033[00m\] " PS1="\[\033[01m\]${_acp_ps1_prefix}\u@\h\\$\[\033[00m\] "
unset _acp_ps1_prefix unset _acp_ps1_prefix
elif [ -n "$ZSH_VERSION" ] elif [ -n "$ZSH_VERSION" ]
then then
autoload -Uz compinit && compinit autoload -Uz compinit && compinit
autoload -Uz history-search-end autoload -Uz history-search-end
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zle -N history-beginning-search-backward-end history-search-end zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end zle -N history-beginning-search-forward-end history-search-end
bindkey -e bindkey -e
bindkey "^[[1;5C" forward-word bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word bindkey "^[[1;5D" backward-word
bindkey "^[[3~" delete-char bindkey "^[[3~" delete-char
bindkey "^[[A" history-beginning-search-backward-end bindkey "^[[A" history-beginning-search-backward-end
bindkey "^[[B" history-beginning-search-forward-end bindkey "^[[B" history-beginning-search-forward-end
bindkey "^[OA" history-beginning-search-backward-end bindkey "^[OA" history-beginning-search-backward-end
bindkey "^[OB" history-beginning-search-forward-end bindkey "^[OB" history-beginning-search-forward-end
PS1="%B%n@%m%#%b " PS1="%B%n@%m%#%b "
else else
# POSIX-compatible prompt. # POSIX-compatible prompt.
if [ "$(uname -s)" = FreeBSD ] if [ "$(uname -s)" = FreeBSD ]
then then
bind "^W" ed-delete-prev-word bind "^W" ed-delete-prev-word
bind "^[[1;5C" em-next-word bind "^[[1;5C" em-next-word
bind "^[[1;5D" ed-prev-word bind "^[[1;5D" ed-prev-word
fi fi
PS1="$(id -un)@$(uname -n | sed 's/\..*$//')$ " PS1="$(id -un)@$(uname -n | sed 's/\..*$//')$ "
fi fi
_acp_add_path () { _acp_add_path () {
if [ -n "$1" ] && [ -d "$1" ] if [ -n "$1" ] && [ -d "$1" ]
then then
case ":$PATH:" in case ":$PATH:" in
*:"$1":*) *:"$1":*)
return return
;; ;;
*) *)
PATH="$PATH:$1" PATH="$PATH:$1"
export PATH export PATH
return return
;; ;;
esac esac
fi fi
} }
# First in the list means first in the path. # First in the list means first in the path.
PATH=/usr/bin PATH=/usr/bin
for dir in "$HOME/.local/bin" \ for dir in "$HOME/.local/bin" \
"$ACP/bin" \ "$ACP/bin" \
"$XDG_DATA_HOME/flatpak/exports/bin" \ "$XDG_DATA_HOME/flatpak/exports/bin" \
"$HOME/.cargo/bin" \ "$HOME/.cargo/bin" \
"$XDG_DATA_HOME/gem/ruby/bin" \ "$XDG_DATA_HOME/gem/ruby/bin" \
/usr/local/bin \ /usr/local/bin \
/usr/local/sbin \ /usr/local/sbin \
/opt/local/bin \ /opt/local/bin \
/opt/local/sbin \ /opt/local/sbin \
/var/lib/flatpak/exports/bin \ /var/lib/flatpak/exports/bin \
/app/bin \ /app/bin \
/usr/sbin \ /usr/sbin \
/bin \ /bin \
/sbin /sbin
do do
_acp_add_path "$dir" _acp_add_path "$dir"
done done
umask 0022 umask 0022
@ -155,35 +155,35 @@ export TIME_STYLE=long-iso # Used by GNU 'ls'.
if [ "$(uname -s)" = Darwin ] if [ "$(uname -s)" = Darwin ]
then then
# MacOS warns about switching from bash to zsh. Silence this. # MacOS warns about switching from bash to zsh. Silence this.
export BASH_SILENCE_DEPRECATION_WARNING=1 export BASH_SILENCE_DEPRECATION_WARNING=1
fi fi
if test -x /usr/bin/tty if [ -x /usr/bin/tty ]
then then
GPG_TTY=$(tty) GPG_TTY=$(tty)
export GPG_TTY export GPG_TTY
fi fi
# Set up Vi/Vim. # Set up Vi/Vim.
if command -v vim > /dev/null if command -v vim > /dev/null
then then
export EDITOR="vim -f" export EDITOR="vim -f"
alias vi=vim alias vi=vim
else else
export EDITOR=vi export EDITOR=vi
fi fi
# Use root's cache instead of having one for root and one for the user. # Use root's cache instead of having one for root and one for the user.
if [ "$(id -u)" -ne 0 ] && [ -x /usr/bin/dnf ] if [ "$(id -u)" -ne 0 ] && [ -x /usr/bin/dnf ]
then then
alias dnf="dnf --cacheonly --nogpgcheck" alias dnf="dnf --cacheonly --nogpgcheck"
fi fi
# Old RHEL releases still have the original yum (not DNF). # Old RHEL releases still have the original yum (not DNF).
if [ -x /usr/bin/yum ] && [ ! -x /usr/bin/dnf ] if [ -x /usr/bin/yum ] && [ ! -x /usr/bin/dnf ]
then then
alias dnf=yum alias dnf=yum
fi fi
alias 7zencrypt="7z a -t7z -p -mhe" alias 7zencrypt="7z a -t7z -p -mhe"
@ -215,26 +215,26 @@ alias fr="LANG=fr_FR.UTF-8"
# Alias dig to drill if dig is not installed. # Alias dig to drill if dig is not installed.
if [ -x /usr/bin/drill ] if [ -x /usr/bin/drill ]
then then
alias dig=drill alias dig=drill
fi fi
# Set up Go. # Set up Go.
if [ -x "$ACP/opt/go/bin/go" ] || [ -x /usr/bin/go ] || [ -x /usr/local/bin/go ] if [ -x "$ACP/opt/go/bin/go" ] || [ -x /usr/bin/go ] || [ -x /usr/local/bin/go ]
then then
export GOPROXY=https://proxy.golang.org export GOPROXY=https://proxy.golang.org
export GOPATH="$XDG_DATA_HOME/go" export GOPATH="$XDG_DATA_HOME/go"
if [ ! -d "$GOPATH" ] if [ ! -d "$GOPATH" ]
then then
mkdir -p "$GOPATH/bin" mkdir -p "$GOPATH/bin"
mkdir -p "$GOPATH/pkg" mkdir -p "$GOPATH/pkg"
mkdir -p "$GOPATH/src" mkdir -p "$GOPATH/src"
fi fi
if [ -x "$ACP/opt/go/bin/go" ] if [ -x "$ACP/opt/go/bin/go" ]
then then
export GOROOT="$ACP/opt/go" export GOROOT="$ACP/opt/go"
_acp_add_path "$GOROOT/bin" _acp_add_path "$GOROOT/bin"
fi fi
_acp_add_path "$GOPATH/bin" _acp_add_path "$GOPATH/bin"
fi fi
alias prun='podman run --rm --interactive --tty --security-opt label=disable --volume "$HOME":"$HOME" --volume "$XDG_RUNTIME_DIR":"$XDG_RUNTIME_DIR" --env XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" --env XDG_SESSION_TYPE=wayland --ipc host' alias prun='podman run --rm --interactive --tty --security-opt label=disable --volume "$HOME":"$HOME" --volume "$XDG_RUNTIME_DIR":"$XDG_RUNTIME_DIR" --env XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" --env XDG_SESSION_TYPE=wayland --ipc host'
@ -243,166 +243,166 @@ alias pruncerts='prun --volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro --volume /
# Set up SSH agent if it's not already running. # Set up SSH agent if it's not already running.
if command -v ssh-agent > /dev/null if command -v ssh-agent > /dev/null
then then
export SSH_AUTH_SOCK="${SSH_AUTH_SOCK:-$XDG_RUNTIME_DIR/ssh-agent.socket}" export SSH_AUTH_SOCK="${SSH_AUTH_SOCK:-$XDG_RUNTIME_DIR/ssh-agent.socket}"
export SSH_AGENT_PID="${SSH_AGENT_PID:-$XDG_RUNTIME_DIR/ssh-agent.pid}" export SSH_AGENT_PID="${SSH_AGENT_PID:-$XDG_RUNTIME_DIR/ssh-agent.pid}"
ssh-add -l > /dev/null 2>&1 ssh-add -l > /dev/null 2>&1
_acp_ssh_agent_exists=$? _acp_ssh_agent_exists=$?
if [ -S "$SSH_AUTH_SOCK" ] && [ $_acp_ssh_agent_exists -eq 2 ] if [ -S "$SSH_AUTH_SOCK" ] && [ $_acp_ssh_agent_exists -eq 2 ]
then then
# Remove stale ssh-agent socket. # Remove stale ssh-agent socket.
rm -f "$SSH_AUTH_SOCK" rm -f "$SSH_AUTH_SOCK"
fi fi
unset _acp_ssh_agent_exists unset _acp_ssh_agent_exists
if [ ! -S "$SSH_AUTH_SOCK" ] if [ ! -S "$SSH_AUTH_SOCK" ]
then then
ssh-agent -a "$SSH_AUTH_SOCK" > /dev/null ssh-agent -a "$SSH_AUTH_SOCK" > /dev/null
fi fi
fi fi
# Make a directory and immediately change to it. # Make a directory and immediately change to it.
mkcd () { mkcd () {
if [ $# -ne 1 ] if [ $# -ne 1 ]
then then
echo "mkcd: incorrect arguments (one directory required)." >&2 echo "mkcd: incorrect arguments (one directory required)." >&2
return 1 return 1
else else
mkdir -p "$1" mkdir -p "$1"
cd "$1" || return cd "$1" || return
fi fi
} }
linapm () { linapm () {
cat /sys/class/power_supply/BAT0/status cat /sys/class/power_supply/BAT0/status
cat /sys/class/power_supply/BAT0/capacity cat /sys/class/power_supply/BAT0/capacity
} }
xa () { xa () {
out=$(xrandr --listactivemonitors | awk 'NR!=1{print " "$NF" "}') out=$(xrandr --listactivemonitors | awk 'NR!=1{print " "$NF" "}')
for monitor in $out for monitor in $out
do do
m=$(echo "$monitor" | sed 's/ //g') m=$(echo "$monitor" | sed 's/ //g')
xrandr --output "$m" --auto xrandr --output "$m" --auto
done done
} }
emacsro () { emacsro () {
emacs "$1" -f view-mode emacs "$1" -f view-mode
} }
# Try to attach to an existing tmux session, else create a new one. # Try to attach to an existing tmux session, else create a new one.
tm () { tm () {
if tmux list-sessions > /dev/null 2>&1 if tmux list-sessions > /dev/null 2>&1
then then
tmux attach-session tmux attach-session
else else
tmux new-session tmux new-session
fi fi
} }
usermotd () { usermotd () {
# OS (kernel) name and version in reverse video. # OS (kernel) name and version in reverse video.
printf "\033[7m$(uname -sr)\033[0m\n" printf "\033[7m$(uname -sr)\033[0m\n"
# Distro name and version on Linux and macOS. # Distro name and version on Linux and macOS.
if [ -r /etc/os-release ] if [ -r /etc/os-release ]
then then
echo " $(. /etc/os-release; echo "$NAME" "$VERSION")" echo " $(. /etc/os-release; echo "$NAME" "$VERSION")"
fi fi
if [ "$(uname -s)" = "Darwin" ] if [ "$(uname -s)" = "Darwin" ]
then then
echo " $(sw_vers -productName) $(sw_vers -productVersion)" echo " $(sw_vers -productName) $(sw_vers -productVersion)"
fi fi
# System uptime and load averages. # System uptime and load averages.
uptime uptime
# SSH keys. # SSH keys.
if command -v ssh-add > /dev/null if command -v ssh-add > /dev/null
then then
ssh-add -l ssh-add -l
fi fi
# Language for the shell. # Language for the shell.
echo "LANG=$LANG" echo "LANG=$LANG"
# Timezone. # Timezone.
if [ -n "$TZ" ] if [ -n "$TZ" ]
then then
echo "TZ=$TZ" echo "TZ=$TZ"
elif [ -x /usr/bin/timedatectl ] && [ "$(systemctl is-system-running)" != offline ] elif [ -x /usr/bin/timedatectl ] && [ "$(systemctl is-system-running)" != offline ]
then then
timedatectl show --property=Timezone | sed 's/Timezone=/TZ=/' timedatectl show --property=Timezone | sed 's/Timezone=/TZ=/'
fi fi
# Shell name and version. # Shell name and version.
if [ -n "$BASH_VERSION" ] if [ -n "$BASH_VERSION" ]
then then
echo "bash $BASH_VERSION" echo "bash $BASH_VERSION"
elif [ -n "$ZSH_VERSION" ] elif [ -n "$ZSH_VERSION" ]
then then
echo "zsh $ZSH_VERSION" echo "zsh $ZSH_VERSION"
else else
echo "SHELL=$SHELL" echo "SHELL=$SHELL"
fi fi
} }
simpletls () { simpletls () {
# Create a self-signed certificate with: # Create a self-signed certificate with:
# openssl req -new -x509 \ # openssl req -new -x509 \
# -keyout $ACP/openssl/$(hostname)-key.pem \ # -keyout $ACP/openssl/$(hostname)-key.pem \
# -out $ACP/openssl/$(hostname-cert.pem # -out $ACP/openssl/$(hostname-cert.pem
if [ "$1" = "-l" ] if [ "$1" = "-l" ]
then then
openssl s_server -cert "$ACP/openssl/$(hostname)-cert.pem" -key "$HOME/data/openssl/$(hostname)-key.pem" -tls1_3 -port "$2" openssl s_server -cert "$ACP/openssl/$(hostname)-cert.pem" -key "$HOME/data/openssl/$(hostname)-key.pem" -tls1_3 -port "$2"
else else
openssl s_client -CAfile "$ACP/openssl/$1-cert.pem" -tls1_3 -connect "$1":"$2" openssl s_client -CAfile "$ACP/openssl/$1-cert.pem" -tls1_3 -connect "$1":"$2"
fi fi
} }
tlscheck () { tlscheck () {
if [ -z "$1" ] if [ -z "$1" ]
then then
echo "Usage: tlscheck hostname:port" >&2 echo "Usage: tlscheck hostname:port" >&2
else else
openssl s_client -connect "$1" </dev/null | openssl x509 -text openssl s_client -connect "$1" </dev/null | openssl x509 -text
fi fi
} }
virtinst () { virtinst () {
_acp_vm_default_nic=enp2s0 _acp_vm_default_nic=enp2s0
if [ $# -ne 1 ] if [ $# -ne 1 ]
then then
virtinst --help virtinst --help
return return
fi fi
case "$1" in case "$1" in
--help) --help)
echo "Usage: virtinst --cdrom /path/to/cdrom.iso vmname" >&2 echo "Usage: virtinst --cdrom /path/to/cdrom.iso vmname" >&2
echo " virtinst --pxe vmname" >&2 echo " virtinst --pxe vmname" >&2
echo " virtinst --import vmname" >&2 echo " virtinst --import vmname" >&2
return return
;; ;;
*) *)
;; ;;
esac esac
virt-install --name $_acp_vm_name \ virt-install --name $_acp_vm_name \
--osinfo linux2022 \ --osinfo linux2022 \
--boot uefi \ --boot uefi \
--cdrom /usr/share/edk2/ovmf/UefiShell.iso \ --cdrom /usr/share/edk2/ovmf/UefiShell.iso \
--disk /var/lib/libvirt/images/${_acp_vm_name}.qcow2,size=20 \ --disk /var/lib/libvirt/images/${_acp_vm_name}.qcow2,size=20 \
--network type=direct,source=${_acp_vm_default_nic},source_mode=bridge \ --network type=direct,source=${_acp_vm_default_nic},source_mode=bridge \
--graphics vnc \ --graphics vnc \
--console pty,target.type=virtio \ --console pty,target.type=virtio \
--autoconsole none --autoconsole none
unset _acp_vm_name unset _acp_vm_name
unset _acp_vm_default_nic unset _acp_vm_default_nic
} }
if [ -r "$XDG_CONFIG_HOME/profile.local" ] if [ -r "$XDG_CONFIG_HOME/profile.local" ]
then then
. "$XDG_CONFIG_HOME/profile.local" . "$XDG_CONFIG_HOME/profile.local"
fi fi

View file

@ -1,20 +1,20 @@
#!/bin/sh #!/bin/sh
if [ -r "$HOME/.profile" ] if [ -r "$HOME/.profile" ]
then then
. "$HOME/.profile" . "$HOME/.profile"
fi fi
case "$-" in case "$-" in
*i*) *i*)
# Shell is interactive. # Shell is interactive.
if [ -r /etc/profile.d/bash_completion.sh ] if [ -r /etc/profile.d/bash_completion.sh ]
then then
. /etc/profile.d/bash_completion.sh . /etc/profile.d/bash_completion.sh
fi fi
usermotd usermotd
;; ;;
*) *)
# Shell is not interactive. # Shell is not interactive.
return 1 return 1
;; ;;
esac esac