2022-09-16 07:42:02 +00:00
|
|
|
#!/bin/sh
|
2023-03-29 12:28:53 +00:00
|
|
|
|
|
|
|
# Start from known core "C" locale. This will get overwritten later.
|
2023-04-16 20:34:30 +00:00
|
|
|
export LANG=C.UTF-8
|
2022-09-16 07:42:02 +00:00
|
|
|
|
|
|
|
# Set up XDG variables. See:
|
|
|
|
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
|
|
export XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
|
|
|
|
export XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS:-/etc/xdg}
|
|
|
|
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
|
|
|
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
|
|
|
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
|
|
export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
|
|
|
|
|
|
|
|
# Set up XDG variables. See:
|
|
|
|
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
|
|
if [ ! -d "$XDG_DATA_HOME" ] ; then install -d -m 0700 "$XDG_DATA_HOME" ; fi
|
|
|
|
if [ ! -d "$XDG_CACHE_HOME" ] ; then install -d -m 0700 "$XDG_CACHE_HOME" ; fi
|
|
|
|
if [ ! -d "$XDG_CONFIG_HOME" ] ; then install -d -m 0700 "$XDG_CONFIG_HOME" ; fi
|
|
|
|
if [ ! -d "$XDG_STATE_HOME" ] ; then install -d -m 0700 "$XDG_STATE_HOME" ; fi
|
|
|
|
if [ ! -d "$HOME/.local/bin" ] ; then install -d -m 0700 "$HOME/.local/bin" ; fi
|
|
|
|
|
|
|
|
# Locale and language.
|
|
|
|
## Clear the existing locale settings and set options I always want.
|
|
|
|
export TZ=Europe/London # Can override this elsewhere if needed.
|
2023-04-16 20:34:30 +00:00
|
|
|
if ! [ -f /run/.containerenv ] && ! [ -f "$XDG_CONFIG_HOME/locale.conf" ] && [ -x /usr/bin/locale ]
|
2022-11-15 21:44:26 +00:00
|
|
|
then
|
2023-04-21 18:04:20 +00:00
|
|
|
LANG="C.UTF-8" /usr/bin/locale > "$XDG_CONFIG_HOME/locale.conf"
|
2022-11-15 21:44:26 +00:00
|
|
|
fi
|
2023-04-16 20:34:30 +00:00
|
|
|
if ! [ -f /run/.containerenv ] && [ -r "$XDG_CONFIG_HOME/locale.conf" ]
|
2022-09-16 07:42:02 +00:00
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
. "$XDG_CONFIG_HOME/locale.conf"
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
2023-03-29 12:28:53 +00:00
|
|
|
export ANSIBLE_NOCOWS=1
|
|
|
|
export BLOCKSIZE=K
|
2023-06-02 13:11:33 +00:00
|
|
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
2023-06-29 10:10:14 +00:00
|
|
|
export DOTNET_NOLOGO=1
|
2023-06-20 18:55:50 +00:00
|
|
|
export DOTNET_ROOT="$HOME/.dotnet" # https://aka.ms/dotnet/download
|
2023-06-29 10:10:14 +00:00
|
|
|
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
2023-03-29 12:28:53 +00:00
|
|
|
export EDITOR=vi
|
|
|
|
export ENV="$HOME/.shrc"
|
|
|
|
export GOTELEMETRY=off
|
|
|
|
export HISTCONTROL=ignorespace:ignoredups
|
|
|
|
export PAGER=less
|
|
|
|
export PAPERSIZE=a4
|
|
|
|
export POWERSHELL_TELEMETRY_OPTOUT=1
|
2023-06-21 18:29:07 +00:00
|
|
|
export POWERSHELL_UPDATE_CHECK=LTS
|
2023-03-29 12:28:53 +00:00
|
|
|
export PYTHONWARNINGS=ignore::UserWarning
|
|
|
|
export VIRSH_DEFAULT_CONNECT_URI=qemu:///session
|
|
|
|
|
2023-03-29 14:00:32 +00:00
|
|
|
if ! [ -x "$HOME/data" ]
|
2023-03-29 12:28:53 +00:00
|
|
|
then
|
2023-03-29 14:00:32 +00:00
|
|
|
install -d -m 0700 "$HOME/data"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -r "$XDG_CONFIG_HOME/user-dirs.dirs" ]
|
|
|
|
then
|
|
|
|
(
|
|
|
|
. "$XDG_CONFIG_HOME/user-dirs.dirs"
|
2023-03-29 17:45:14 +00:00
|
|
|
mkdir -p "$XDG_DESKTOP_DIR"
|
|
|
|
mkdir -p "$XDG_DOCUMENTS_DIR"
|
|
|
|
mkdir -p "$XDG_DOWNLOAD_DIR"
|
|
|
|
mkdir -p "$XDG_MUSIC_DIR"
|
|
|
|
mkdir -p "$XDG_PICTURES_DIR"
|
|
|
|
mkdir -p "$XDG_PUBLICSHARE_DIR"
|
|
|
|
mkdir -p "$XDG_TEMPLATES_DIR"
|
|
|
|
mkdir -p "$XDG_VIDEOS_DIR"
|
2023-03-29 17:45:47 +00:00
|
|
|
|
|
|
|
if [ -d "$HOME/Documents" ]; then rmdir "$HOME/Documents"; fi
|
|
|
|
if [ -d "$HOME/Music" ]; then rmdir "$HOME/Music" ; fi
|
|
|
|
if [ -d "$HOME/Pictures" ]; then rmdir "$HOME/Pictures" ; fi
|
|
|
|
if [ -d "$HOME/Videos" ]; then rmdir "$HOME/Videos" ; fi
|
2023-03-29 14:00:32 +00:00
|
|
|
)
|
2023-03-29 12:28:53 +00:00
|
|
|
fi
|
|
|
|
|
2022-09-16 07:42:02 +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 [ -x /usr/lib/snapd/snapd ] && [ -n "${XDG_DATA_DIRS##*${_snap_xdg_path}}" ] && [ -n "${XDG_DATA_DIRS##*${_snap_xdg_path}:*}" ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
XDG_DATA_DIRS="${XDG_DATA_DIRS}:${_snap_xdg_path}"
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
unset _snap_xdg_path
|
2022-12-11 20:18:26 +00:00
|
|
|
# Same as above for Flatpak.
|
|
|
|
_flatpak_xdg_path="$XDG_DATA_HOME/flatpak/exports/share"
|
|
|
|
if [ -x /usr/bin/flatpak ] && [ -n "${XDG_DATA_DIRS##*${_flatpak_xdg_path}}" ] && [ -n "${XDG_DATA_DIRS##*${_flatpak_xdg_path}:*}" ]
|
|
|
|
then
|
|
|
|
XDG_DATA_DIRS="${XDG_DATA_DIRS}:${_flatpak_xdg_path}"
|
|
|
|
fi
|
|
|
|
unset _flatpak_xdg_path
|
2022-09-16 07:42:02 +00:00
|
|
|
|
|
|
|
# Bash-specific settings that will not work in other Bourne-compatible shells.
|
|
|
|
if [ -n "$BASH_VERSION" ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
set -o emacs
|
|
|
|
set -o noclobber
|
|
|
|
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'
|
|
|
|
bind 'set enable-bracketed-paste off'
|
|
|
|
export BASH_ENV="$HOME/.bashrc"
|
|
|
|
|
2023-02-06 21:23:40 +00:00
|
|
|
if [ -e /.flatpak-info ]
|
2022-11-28 22:45:54 +00:00
|
|
|
then
|
|
|
|
_acp_ps1_prefix="*"
|
|
|
|
fi
|
|
|
|
PS1="\[\033[01m\]${_acp_ps1_prefix}\u@\h\\$\[\033[00m\] "
|
|
|
|
unset _acp_ps1_prefix
|
2022-09-16 07:42:02 +00:00
|
|
|
|
|
|
|
elif [ -n "$ZSH_VERSION" ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
autoload -Uz compinit && compinit
|
|
|
|
autoload -Uz history-search-end
|
|
|
|
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-forward-end history-search-end
|
|
|
|
bindkey -e
|
|
|
|
bindkey "^[[1;5C" forward-word
|
|
|
|
bindkey "^[[1;5D" backward-word
|
|
|
|
bindkey "^[[3~" delete-char
|
|
|
|
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
|
|
|
|
|
|
|
|
PS1="%B%n@%m%#%b "
|
2022-09-16 07:42:02 +00:00
|
|
|
|
|
|
|
else
|
2022-11-28 22:45:54 +00:00
|
|
|
# POSIX-compatible prompt.
|
|
|
|
if [ "$(uname -s)" = FreeBSD ]
|
|
|
|
then
|
|
|
|
bind "^W" ed-delete-prev-word
|
|
|
|
bind "^[[1;5C" em-next-word
|
|
|
|
bind "^[[1;5D" ed-prev-word
|
|
|
|
fi
|
|
|
|
PS1="$(id -un)@$(uname -n | sed 's/\..*$//')$ "
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
_acp_add_path () {
|
2022-11-28 22:45:54 +00:00
|
|
|
if [ -n "$1" ] && [ -d "$1" ]
|
|
|
|
then
|
|
|
|
case ":$PATH:" in
|
|
|
|
*:"$1":*)
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PATH="$PATH:$1"
|
|
|
|
export PATH
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
2022-10-13 10:18:39 +00:00
|
|
|
# First in the list means first in the path.
|
2023-02-18 10:40:41 +00:00
|
|
|
# Flatpak extensions are named `org.freedesktop.Sdk.Extension.NAME` and get
|
|
|
|
# installed to `/usr/lib/sdk/NAME/bin`.
|
2022-10-13 10:18:39 +00:00
|
|
|
PATH=/usr/bin
|
2022-09-16 07:42:02 +00:00
|
|
|
for dir in "$HOME/.local/bin" \
|
2023-02-18 10:38:27 +00:00
|
|
|
"$ACP/bin" \
|
2023-05-24 09:13:19 +00:00
|
|
|
"$XDG_DATA_HOME/JetBrains/Toolbox/scripts" \
|
2023-05-16 15:16:29 +00:00
|
|
|
/ucrt64/bin \
|
2023-02-18 10:40:41 +00:00
|
|
|
/usr/lib/sdk/texlive/bin \
|
|
|
|
/usr/lib/sdk/texlive/bin/x86_64-linux \
|
|
|
|
/usr/lib/sdk/rust-nightly/bin \
|
|
|
|
/usr/lib/sdk/rust-stable/bin \
|
|
|
|
/usr/lib/sdk/golang/bin \
|
2023-02-18 10:38:27 +00:00
|
|
|
"$XDG_DATA_HOME/flatpak/exports/bin" \
|
2023-06-13 18:05:37 +00:00
|
|
|
"$HOME/.dotnet/tools" \
|
2023-02-18 10:38:27 +00:00
|
|
|
"$HOME/.cargo/bin" \
|
2023-05-01 20:52:46 +00:00
|
|
|
"$HOME/opt/go/bin" \
|
2023-02-18 10:38:27 +00:00
|
|
|
"$XDG_DATA_HOME/gem/ruby/bin" \
|
2023-03-09 20:38:41 +00:00
|
|
|
"$HOME/opt/node/bin" \
|
2023-02-18 10:38:27 +00:00
|
|
|
/usr/local/bin \
|
|
|
|
/usr/local/sbin \
|
|
|
|
/opt/local/bin \
|
|
|
|
/opt/local/sbin \
|
|
|
|
/var/lib/flatpak/exports/bin \
|
|
|
|
/app/bin \
|
|
|
|
/usr/sbin \
|
|
|
|
/bin \
|
|
|
|
/sbin
|
2022-09-16 07:42:02 +00:00
|
|
|
do
|
2022-11-28 22:45:54 +00:00
|
|
|
_acp_add_path "$dir"
|
2022-09-16 07:42:02 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Other exports.
|
|
|
|
export PS1="${PS1:-\$ }" # Fallback prompt.
|
|
|
|
export HISTFILE=""
|
|
|
|
export TIME_STYLE=long-iso # Used by GNU 'ls'.
|
|
|
|
|
2023-05-02 10:31:21 +00:00
|
|
|
if [ "$XDG_SESSION_TYPE" = "wayland" ]
|
|
|
|
then
|
|
|
|
export MOZ_ENABLE_WAYLAND=1
|
|
|
|
fi
|
|
|
|
|
2022-09-16 07:42:02 +00:00
|
|
|
if [ "$(uname -s)" = Darwin ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
# MacOS warns about switching from bash to zsh. Silence this.
|
|
|
|
export BASH_SILENCE_DEPRECATION_WARNING=1
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
2022-11-28 22:45:54 +00:00
|
|
|
if [ -x /usr/bin/tty ]
|
2022-09-16 07:42:02 +00:00
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
GPG_TTY=$(tty)
|
|
|
|
export GPG_TTY
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Set up Vi/Vim.
|
|
|
|
if command -v vim > /dev/null
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
export EDITOR="vim -f"
|
|
|
|
alias vi=vim
|
2022-09-16 07:42:02 +00:00
|
|
|
else
|
2022-11-28 22:45:54 +00:00
|
|
|
export EDITOR=vi
|
2023-02-06 21:25:48 +00:00
|
|
|
alias vim=vi
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Use root's cache instead of having one for root and one for the user.
|
|
|
|
if [ "$(id -u)" -ne 0 ] && [ -x /usr/bin/dnf ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
alias dnf="dnf --cacheonly --nogpgcheck"
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Old RHEL releases still have the original yum (not DNF).
|
|
|
|
if [ -x /usr/bin/yum ] && [ ! -x /usr/bin/dnf ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
alias dnf=yum
|
2022-09-16 07:42:02 +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 f=fossil
|
|
|
|
alias ip="ip -c"
|
|
|
|
alias isocal="cal --iso --reform=iso --monday --week"
|
2023-01-15 15:28:33 +00:00
|
|
|
alias isodate="date +'Date: %Y-%m-%d%nTime: %H:%M:%S%nZone: %:z%n%nWeek: %G-W%V-%u%nDay: %Y-%j'"
|
2022-09-16 07:42:02 +00:00
|
|
|
alias la="ls -a"
|
|
|
|
alias ll="ls -l"
|
|
|
|
alias ls="command ls -F"
|
|
|
|
alias now="date +%Y%m%dT%H%M%S%z"
|
2023-02-09 13:30:48 +00:00
|
|
|
alias nowh="date +%Y-%m-%dT%H:%M:%S%:z"
|
2022-09-16 07:42:02 +00:00
|
|
|
alias nowu="date -u +%Y%m%dT%H%M%SZ"
|
2022-10-13 10:25:03 +00:00
|
|
|
alias sdk="flatpak run --command=/bin/bash --share=network --filesystem=home:rw org.freedesktop.Sdk"
|
2022-10-12 12:19:43 +00:00
|
|
|
alias sdk-gnome="flatpak run --command=/bin/bash --share=network --filesystem=home:rw org.gnome.Sdk"
|
2022-09-16 07:42:02 +00:00
|
|
|
alias streamenc="openssl aes-256-cbc -pbkdf2 -in - -out - -e"
|
|
|
|
alias streamdec="openssl aes-256-cbc -pbkdf2 -in - -out - -d"
|
|
|
|
alias wgr=wordgrinder
|
|
|
|
alias ytmp3="youtube-dl -q -x --audio-format=mp3"
|
|
|
|
alias zlu="zypper list-updates"
|
|
|
|
|
|
|
|
# Language aliases.
|
|
|
|
## Fedora/RHEL/CentOS: dnf install glibc-langpack-{en,fr}
|
2022-09-19 12:14:30 +00:00
|
|
|
alias C="LANG=C.UTF-8"
|
2022-09-16 07:42:02 +00:00
|
|
|
alias fr="LANG=fr_FR.UTF-8"
|
2023-04-21 18:04:20 +00:00
|
|
|
alias gb="LANG=en_GB.UTF-8"
|
|
|
|
alias us="LANG=en_US.UTF-8"
|
2022-09-16 07:42:02 +00:00
|
|
|
|
|
|
|
# Alias dig to drill if dig is not installed.
|
|
|
|
if [ -x /usr/bin/drill ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
alias dig=drill
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Set up Go.
|
|
|
|
if [ -x "$ACP/opt/go/bin/go" ] || [ -x /usr/bin/go ] || [ -x /usr/local/bin/go ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
export GOPROXY=https://proxy.golang.org
|
|
|
|
export GOPATH="$XDG_DATA_HOME/go"
|
|
|
|
if [ ! -d "$GOPATH" ]
|
|
|
|
then
|
|
|
|
mkdir -p "$GOPATH/bin"
|
|
|
|
mkdir -p "$GOPATH/pkg"
|
|
|
|
mkdir -p "$GOPATH/src"
|
|
|
|
fi
|
|
|
|
if [ -x "$ACP/opt/go/bin/go" ]
|
|
|
|
then
|
|
|
|
export GOROOT="$ACP/opt/go"
|
|
|
|
_acp_add_path "$GOROOT/bin"
|
|
|
|
fi
|
|
|
|
_acp_add_path "$GOPATH/bin"
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
2023-03-21 14:51:42 +00:00
|
|
|
# Basic and extra prun (podman run) aliases.
|
|
|
|
alias prun='podman run --rm --interactive --tty --security-opt label=disable'
|
2023-04-03 15:11:56 +00:00
|
|
|
alias prunx='prun --volume "$HOME":/root --volume "$XDG_RUNTIME_DIR":"$XDG_RUNTIME_DIR" --env XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" --env XDG_SESSION_TYPE=wayland --ipc host'
|
2023-03-21 14:51:42 +00:00
|
|
|
|
|
|
|
# Tool-specific podman aliases.
|
|
|
|
alias pruncerts='prunx --volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro --volume /etc/ssl/certs:/etc/ssl/certs:ro'
|
|
|
|
alias padoc='prun --volume "$(pwd)":/documents docker.io/asciidoctor/docker-asciidoctor:latest'
|
|
|
|
alias pgo='prun --volume "$(pwd)":/devel --workdir /devel docker.io/library/golang:latest'
|
|
|
|
alias prust='prun --volume "$(pwd)":/devel --workdir /devel docker.io/library/rust:latest'
|
2022-09-16 07:42:02 +00:00
|
|
|
|
|
|
|
# Set up SSH agent if it's not already running.
|
|
|
|
if command -v ssh-agent > /dev/null
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
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}"
|
|
|
|
ssh-add -l > /dev/null 2>&1
|
|
|
|
_acp_ssh_agent_exists=$?
|
|
|
|
if [ -S "$SSH_AUTH_SOCK" ] && [ $_acp_ssh_agent_exists -eq 2 ]
|
|
|
|
then
|
|
|
|
# Remove stale ssh-agent socket.
|
|
|
|
rm -f "$SSH_AUTH_SOCK"
|
|
|
|
fi
|
|
|
|
unset _acp_ssh_agent_exists
|
|
|
|
if [ ! -S "$SSH_AUTH_SOCK" ]
|
|
|
|
then
|
|
|
|
ssh-agent -a "$SSH_AUTH_SOCK" > /dev/null
|
|
|
|
fi
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Make a directory and immediately change to it.
|
|
|
|
mkcd () {
|
2022-11-28 22:45:54 +00:00
|
|
|
if [ $# -ne 1 ]
|
|
|
|
then
|
|
|
|
echo "mkcd: incorrect arguments (one directory required)." >&2
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
mkdir -p "$1"
|
|
|
|
cd "$1" || return
|
|
|
|
fi
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
linapm () {
|
2022-11-28 22:45:54 +00:00
|
|
|
cat /sys/class/power_supply/BAT0/status
|
|
|
|
cat /sys/class/power_supply/BAT0/capacity
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xa () {
|
2022-11-28 22:45:54 +00:00
|
|
|
out=$(xrandr --listactivemonitors | awk 'NR!=1{print " "$NF" "}')
|
|
|
|
for monitor in $out
|
|
|
|
do
|
|
|
|
m=$(echo "$monitor" | sed 's/ //g')
|
|
|
|
xrandr --output "$m" --auto
|
|
|
|
done
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
emacsro () {
|
2022-11-28 22:45:54 +00:00
|
|
|
emacs "$1" -f view-mode
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Try to attach to an existing tmux session, else create a new one.
|
|
|
|
tm () {
|
2022-11-28 22:45:54 +00:00
|
|
|
if tmux list-sessions > /dev/null 2>&1
|
|
|
|
then
|
|
|
|
tmux attach-session
|
|
|
|
else
|
|
|
|
tmux new-session
|
|
|
|
fi
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usermotd () {
|
2022-11-28 22:45:54 +00:00
|
|
|
# OS (kernel) name and version in reverse video.
|
2023-02-16 21:11:41 +00:00
|
|
|
printf '\033[7m%s\033[0m\n' "$(uname -sr)"
|
2022-11-28 22:45:54 +00:00
|
|
|
|
|
|
|
# Distro name and version on Linux and macOS.
|
|
|
|
if [ -r /etc/os-release ]
|
|
|
|
then
|
2023-02-15 15:31:13 +00:00
|
|
|
echo " $(. /etc/os-release; echo "${PRETTY_NAME:-${NAME:-${ID:-unknown}} ${VERSION:-${VERSION_ID:-??}}}")"
|
2022-11-28 22:45:54 +00:00
|
|
|
fi
|
|
|
|
if [ "$(uname -s)" = "Darwin" ]
|
|
|
|
then
|
|
|
|
echo " $(sw_vers -productName) $(sw_vers -productVersion)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# System uptime and load averages.
|
|
|
|
uptime
|
|
|
|
|
|
|
|
# SSH keys.
|
|
|
|
if command -v ssh-add > /dev/null
|
|
|
|
then
|
|
|
|
ssh-add -l
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Language for the shell.
|
|
|
|
echo "LANG=$LANG"
|
|
|
|
|
|
|
|
# Timezone.
|
|
|
|
if [ -n "$TZ" ]
|
|
|
|
then
|
|
|
|
echo "TZ=$TZ"
|
|
|
|
elif [ -x /usr/bin/timedatectl ] && [ "$(systemctl is-system-running)" != offline ]
|
|
|
|
then
|
|
|
|
timedatectl show --property=Timezone | sed 's/Timezone=/TZ=/'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Shell name and version.
|
|
|
|
if [ -n "$BASH_VERSION" ]
|
|
|
|
then
|
|
|
|
echo "bash $BASH_VERSION"
|
|
|
|
elif [ -n "$ZSH_VERSION" ]
|
|
|
|
then
|
|
|
|
echo "zsh $ZSH_VERSION"
|
|
|
|
else
|
|
|
|
echo "SHELL=$SHELL"
|
|
|
|
fi
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
simpletls () {
|
2022-11-28 22:45:54 +00:00
|
|
|
# Create a self-signed certificate with:
|
|
|
|
# openssl req -new -x509 \
|
|
|
|
# -keyout $ACP/openssl/$(hostname)-key.pem \
|
|
|
|
# -out $ACP/openssl/$(hostname-cert.pem
|
|
|
|
if [ "$1" = "-l" ]
|
|
|
|
then
|
|
|
|
openssl s_server -cert "$ACP/openssl/$(hostname)-cert.pem" -key "$HOME/data/openssl/$(hostname)-key.pem" -tls1_3 -port "$2"
|
|
|
|
else
|
|
|
|
openssl s_client -CAfile "$ACP/openssl/$1-cert.pem" -tls1_3 -connect "$1":"$2"
|
|
|
|
fi
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tlscheck () {
|
2022-11-28 22:45:54 +00:00
|
|
|
if [ -z "$1" ]
|
|
|
|
then
|
|
|
|
echo "Usage: tlscheck hostname:port" >&2
|
|
|
|
else
|
|
|
|
openssl s_client -connect "$1" </dev/null | openssl x509 -text
|
|
|
|
fi
|
2022-09-16 07:42:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ -r "$XDG_CONFIG_HOME/profile.local" ]
|
|
|
|
then
|
2022-11-28 22:45:54 +00:00
|
|
|
. "$XDG_CONFIG_HOME/profile.local"
|
2022-09-16 07:42:02 +00:00
|
|
|
fi
|