git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/.bash
diff options
context:
space:
mode:
Diffstat (limited to '.bash')
-rw-r--r--.bash/aliases.bash89
-rw-r--r--.bash/exec.bash26
-rw-r--r--.bash/postexec.bash22
-rw-r--r--.bash/prompt.bash186
-rw-r--r--.bash/vars.bash37
5 files changed, 311 insertions, 49 deletions
diff --git a/.bash/aliases.bash b/.bash/aliases.bash
index b66218c..dd36794 100644
--- a/.bash/aliases.bash
+++ b/.bash/aliases.bash
@@ -6,20 +6,49 @@
if [ "$TERM" != "dumb" ];then
eval "$(dircolors -b)"
alias ls="ls --color=auto"
- alias grep="grep --color=auto"
- alias egrep="egrep --color=auto"
+ case "$OSNAME" in
+ 'sunos') ;;
+ *)
+ alias grep="grep --color=auto"
+ alias egrep="egrep --color=auto"
+ ;;
+ esac
fi
+# shellcheck disable=SC2139
+if [ -n "$EDITOR" ]; then
+ alias editor="$EDITOR"
+elif [ -n "$VISUAL" ]; then
+ alias editor="$VISUAL"
+elif [ -x "/usr/bin/vim" ]; then
+ alias editor="/usr/bin/vim"
+elif [ -x "/usr/bin/vi" ]; then
+ alias editor="/usr/bin/vi"
+else
+ alias editor="/usr/bin/edit"
+fi
+alias lst="ls -l --time-style=full-iso"
alias cls=' echo -ne "\033c"'
alias pip-update="sudo pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 sudo pip install -U"
alias matrix='cmatrix -sbu6 -C cyan'
+alias tbc='tbclock -e -H2 -M7 -S3'
command -v colordiff >/dev/null 2>&1&&alias diff="colordiff"
-command -v colormake >/dev/null 2>&1&&alias make="colormake"
+#command -v colormake >/dev/null 2>&1&&alias make="colormake"
alias perllint="perl -Mstrict -Mdiagnostics -cw"
alias scredit='gimp "${SCRSHDIR}/$(ls -rt1 $SCRSHDIR/|tail -n1)"'
alias scrview='pqiv -i "${SCRSHDIR}/$(ls -rt1 $SCRSHDIR/|tail -n1)"'
+alias scrls='ls -l "${SCRSHDIR}/$(ls -rt1 $SCRSHDIR/|tail -n1)"'
alias fuck='sudo $(history -p \!\!)'
alias x509-out='openssl x509 -text -certopt no_version,no_pubkey,no_sigdump,no_aux,no_header -noout -in'
-alias psgrep='ps -fp "$(pgrep -d, -x ssh-agent)"'
+alias isocreate='rm -vf /tmp/image.iso && mkisofs -v -r -J -translation-table -hide-joliet-trans-tbl -iso-level 4 -o /tmp/image.iso'
+#alias isoburn='sudo cdrecord -v -speed=10 dev=/dev/sr0 -data'
+alias isoburn='sudo cdrecord -v dev=/dev/sr0 -data'
+# voice messages e.g. for whatsapp (on libpurple). use "voicemsg OUTPUT.ogg"
+alias voicemsg='ffmpeg -f pulse -i default -ac 1 -ar 16000 -c:a libopus -y'
+if command -v colordiff > /dev/null;then alias diff="colordiff";fi
+# aliases like this are relevant if you use multiple passwordstore stores, e.g.
+# your common store is a department-wide one but you still need to store personal credentials
+alias ppass='PASSWORD_STORE_DIR=~/.password-store pass'
+alias ifs='printf "%q\\n" "$IFS "'
# ----- CHOO CHOO ----- #
if command -v sl >/dev/null;then
alias sl='sl -e'
@@ -60,20 +89,40 @@ alias startxmonad="sxs xmonad"
alias saa="source ~/.ssh/sshenv;ssh-add >/dev/null 2>&1;ssh-add -l"
alias sshr='ssh -o StrictHostKeyChecking=no'
alias sshk='ssh -o PasswordAuthentication=yes -o PreferredAuthentications=keyboard-interactive,password -o PubkeyAuthentication=no'
+alias sshg="ssh-with-gpg"
function add-sshagent-init {
for KEY in "${SSHKEYS[@]}";do
- ssh-add "$KEY"
+ FFPRINT="$(ssh-keygen -Esha256 -lf "$KEY")" || return 1
+ if ! ssh-add -l 2>/dev/null | grep "$FFPRINT" >/dev/null; then
+ ssh-add -q "$KEY"
+ fi
done
}
+alias sshmaster='ssh -O'
# ----- FS ----- #
xstat() {
for target in "${@}";do
+ # shellcheck disable=SC2012
inode=$(ls -di "${target}"|cut -d ' ' -f 1)
fs=$(df "${target}"|tail -n 1|awk '{print $1}')
crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | grep -oP 'crtime.*--\s*\K.*')
printf "%s\t%s\n" "${crtime}" "${target}"
done
}
+# ----- PACKAGE MANAGERS ----- #
+if [ -x "/usr/bin/paru" ];then
+ alias pkgclean="paru --noconfirm -Sc"
+elif [ -x "/usr/bin/pikaur" ];then
+ alias pkgclean="pikaur --noconfirm -Sc"
+elif [ -x "/usr/bin/pacman" ];then
+ alias pkgclean="/usr/bin/sudo /usr/bin/pacman --noconfirm -Sc"
+elif [ -x "/usr/bin/apt" ];then
+ alias pkgclean="/usr/bin/sudo /usr/bin/apt clean"
+elif [ -x "/usr/bin/dnf" ];then
+ alias pkgclean="/usr/bin/sudo /usr/bin/dnf clean packages"
+elif [ -x "/usr/bin/zypper" ];then
+ alias pkgclean="/usr/bin/sudo /usr/bin/zypper clean"
+fi
# ----- GRAFANA ----- #
if command -v grafana-cli >/dev/null;then
alias gfpi='sudo grafana-cli plugins install'
@@ -132,6 +181,7 @@ alias certshow="certmgr -L -n"
# ----- APPLICATION CONTROL ----- #
alias browser-set='xdg-settings set default-web-browser'
alias browser-get='xdg-settings get default-web-browser'
+alias default-desktop-apps="editor ~/.config/mimeapps.list"
# ----- CONTAINERS ----- #
if command -v podman >/dev/null;then
alias pcl="podman container list"
@@ -157,3 +207,32 @@ if command -v podman >/dev/null;then
alias pnd="podman network disconnect"
alias ppd="podman pod stop"
fi
+# ----- PUPPET + RUBY ----- #
+# ...yeah, I'm mostly doing ruby stuff for Puppet, erm I mean
+# OpenVox (now that Perforce have turned the Puppet world to a burning heap of garbage)
+alias bake="bundle exec rake"
+# ----- OTHER STUFF ----- #
+for cmmd in batcat bat; do
+ if command -v "$cmmd" > /dev/null; then
+ # shellcheck disable=SC2139
+ alias cat="${cmmd} --tabs 4 --wrap never --paging never --style 'plain,rule'"
+ # shellcheck disable=SC2139
+ alias less="${cmmd} --tabs 4 --wrap never --paging always --style 'plain,rule'"
+ alias plain-cat='/usr/bin/cat'
+ alias plc='/usr/bin/cat'
+ alias plain-less='/usr/bin/less'
+ alias pll='/usr/bin/less'
+ export MANPAGER="sh -c 'col -bx | ${cmmd} -l man -p'"
+ export MANROFFOPT="-c"
+ break
+ fi
+done
+if command -v 'thefuck' > /dev/null; then
+ alias wtf='thefuck $(fc -nl -1)'
+fi
+# Flake8. Nice linter, but...
+# They kneeled to USER STUPIDITY when it comes to configuration. Wut?
+# https://flake8.pycqa.org/en/latest/release-notes/4.0.0.html#backwards-incompatible-changes
+# --> https://github.com/pycqa/flake8/pull/1404
+# Users were confused, so ~/.config/flake8 is not supported anymore. lelkek.
+alias flake8='flake8 --config ${HOME}/.config/flake8'
diff --git a/.bash/exec.bash b/.bash/exec.bash
index ffbeaae..aeba7ca 100644
--- a/.bash/exec.bash
+++ b/.bash/exec.bash
@@ -7,10 +7,30 @@ set bell-style visible
# start ssh agent. this script will not try to run a new instance
# (unless we specified -f, which we don't).
-if echo "${SSHAGH[@]}" | fgrep --word-regexp "$(hostname -f)";then
- "$HOME/bin/ssh-agent-launcher" -q
+SSHRUN=0
+case "$OSNAME" in
+ 'sunos')
+ if echo "${SSHAGH[@]}" | grep -E "^$(cat /etc/nodename)\$" > /dev/null; then
+ SSHRUN=1
+ fi
+ ;;
+ *)
+ if echo "${SSHAGH[@]}" | grep -F --word-regexp "$(hostname -f)" > /dev/null;then
+ SSHRUN=1
+ fi
+ ;;
+esac
+if [ "$SSHRUN" -eq 1 ]; then
+ # do not launch from SSH session, conflicts with user logging on locally afterwards
+ if [ -z "$SSH_TTY" ];then
+ "$HOME/bin/ssh-agent-launcher" -q
+ if ! pgrep -au "$(id -u)" dirmngr >/dev/null;then
+ gpg-connect-agent --dirmngr /bye 2>/dev/null
+ gpg --list-secret-keys >/dev/null 2>&1
+ fi
+ fi
fi
# because on some hosts the login path is fucked, unset in .local
# if it causes irritation:
-cd ~ || cd || exit 151
+cd ~ || cd || return 151
diff --git a/.bash/postexec.bash b/.bash/postexec.bash
index b2f257e..8beee31 100644
--- a/.bash/postexec.bash
+++ b/.bash/postexec.bash
@@ -1,4 +1,24 @@
declare -x SSH_AUTH_SOCK SSH_AGENT_PID
if [ -n "$SSHENVFILE" ] && [ -r "$SSHENVFILE" ];then
- source "$SSHENVFILE"
+ if source "$SSHENVFILE"; then
+ case "$OSNAME" in
+ 'sunos')
+ if echo "${SSHAGH[@]}"|tr ' ' '\n'|grep -E "^$(cat /etc/nodename)\$"; then
+ add-sshagent-init
+ fi
+ ;;
+ *)
+ if echo "${SSHAGH[@]}"|tr ' ' '\n'|grep -P "^$(hostname -f)\$" > /dev/null;then
+ add-sshagent-init
+ fi
+ ;;
+ esac
+ fi
fi
+for gitpsrc in "/usr/share/git/git-prompt.sh" "/usr/local/share/git/git-prompt.sh" \
+ "/usr/share/git-completion/prompt.sh" "/usr/local/share/git-completion/prompt.sh"; do
+ if [ -r "$gitpsrc" ]; then
+ source "$gitpsrc"
+ break
+ fi
+done
diff --git a/.bash/prompt.bash b/.bash/prompt.bash
index c34e557..6ac081b 100644
--- a/.bash/prompt.bash
+++ b/.bash/prompt.bash
@@ -4,61 +4,148 @@
# ----- PROMPT COLOURS ----- #
fgcolor () {
#echo "\\[\\033[38;5;"$1"m\\]"
- echo "\033[38;5;${1}m"
+ printf '\033[38;5;%bm' "$1"
+}
+fgtcolor () {
+ printf '\033[38;2;%b;%b;%bm' "$1" "$2" "$3"
}
bgcolor () {
#echo "\\[\\033[48;5;"$1"m\\]"
- echo "\033[48;5;${1}m"
+ printf '\033[48;5;%bm' "$1"
}
# This is Solaris bash compatible, so we cannot use + here for "at least once) but instead use the
# stupid old asterisk (*). Well, here hetting "no digits" practically won't hurt.
MYUID="$(id|sed 's/.*uid=\([0-9]*\).*/\1/g')";export MYUID
# ...because "empty" will hit the "any" condition in the end :)
+if [ -r '/etc/os-release' ]; then
+ OSMAJVER="$(grep '^VERSION_ID' /etc/os-release 2>/dev/null|awk -F= '{print $NF}'|sed 's/"//g'|awk -F\. '{print $1}')"
+fi
case "$MYUID" in
0)
+ FGC1="fgcolor 88"
case "$OSNAME" in
- debian) FGC1="fgcolor 88";FGC2="fgcolor 25";FGC3="fgcolor 38";;
- arch) FGC1="fgcolor 88";FGC2="fgcolor 24";FGC3="fgcolor 240";;
- redhat|fedora) FGC1="fgcolor 160";FGC2="fgcolor 88";FGC3="fgcolor 203";;
+ debian)
+ # Debian 12 = emerald
+ if [ "$OSMAJVER" -ge 12 ];then
+ FGC3="fgcolor 36";FGC2="fgtcolor 155 15 64"
+ else
+ FGC3="fgcolor 38";FGC2="fgtcolor 155 15 64"
+ fi
+ ;;
+ arch) FGC2="fgcolor 24";FGC3="fgcolor 240";;
+ redhat|rhel) FGC1="fgcolor 23";FGC2="fgcolor 88";FGC3="fgcolor 203";;
+ fedora) FGC1="fgcolor 160";FGC2="fgcolor 88";FGC3="fgcolor 203";;
# with the advent of Rocky, we'll match the time to SUSE's blue and the hostname to
# the colour of Geeko:
- #*suse|aix) FGC1="fgcolor 88";FGC2="fgcolor 22";FGC3="fgcolor 41";;
- *sles*) FGC1="fgcolor 88";FGC2="fgcolor 22";FGC3="fgcolor 83";;
- *suse|aix) FGC1="fgcolor 88";FGC2="fgcolor 30";FGC3="fgcolor 83";;
- *centos*) FGC1="fgcolor 88";FGC2="fgcolor 25";FGC3="fgcolor 208";;
- *solaris) FGC1="fgcolor 88";FGC2="fgcolor 31";FGC3="fgcolor 124";;
- ubuntu) FGC1="fgcolor 88";FGC2="fgcolor 130";FGC3="fgcolor 215";;
- rasp*) FGC1="fgcolor 88";FGC2="fgcolor 253";FGC3="fgcolor 126";;
- rocky) FGC1="fgcolor 88";FGC2="fgcolor 22";FGC3="fgcolor 41";;
- *) FGC1="fgcolor 88";FGC2="fgcolor 240";FGC3="fgcolor 244";;
+ #*suse|aix) FGC2="fgcolor 22";FGC3="fgcolor 41";;
+ *sles*) FGC2="fgcolor 22";FGC3="fgcolor 83";;
+ *suse*)
+ case "$OSNAME" in
+ *leap) FGC2="fgcolor 214";FGC3="fgcolor 83";;
+ *) FGC2="fgcolor 30";FGC3="fgcolor 83";;
+ esac
+ ;;
+ aix) FGC2="fgcolor 238";FGC3="fgcolor 83";;
+ *centos*) FGC2="fgcolor 25";FGC3="fgcolor 208";;
+ *solaris) FGC2="fgcolor 63";FGC3="fgcolor 124";;
+ ubuntu)
+ if [ "$OSMAJVER" -ge 24 ];then
+ if printf "%b" "$TERM"|grep -E 'xterm|256' > /dev/null;then
+ FGC2="fgcolor 125";FGC3="fgcolor 202"
+ else
+ FGC2="fgcolor 53";FGC3="fgcolor 184"
+ fi
+ elif [ "$OSMAJVER" -ge 22 ];then
+ if printf "%b" "$TERM"|grep -E 'xterm|256' > /dev/null;then
+ FGC2="fgcolor 208";FGC3="fgcolor 89"
+ else
+ FGC2="fgcolor 184";FGC3="fgcolor 53"
+ fi
+ else
+ FGC2="fgcolor 130";FGC3="fgcolor 215"
+ fi
+ ;;
+ rasp*) FGC2="fgcolor 253";FGC3="fgcolor 125";;
+ rocky) FGC2="fgcolor 240";FGC3="fgcolor 41";;
+ alma*) FGC1="fgcolor 28";FGC2="fgcolor 88";FGC3="fgcolor 39";;
+ sunos) FGC2="fgcolor 75";FGC3="fgcolor 130";;
+ nobara) FGC2="fgcolor 133";FGC3="fgcolor 63";;
+ *) FGC2="fgcolor 240";FGC3="fgcolor 244";;
esac
+ if [ -n "$TERMUX_APK_RELEASE" ]; then
+ if [ "$TERMUX_APK_RELEASE" == "F_DROID" ]; then
+ FGC2="fgcolor 27";FGC3="fgcolor 35"
+ fi
+ fi
;;
*)
+ FGC2="fgcolor 253"
case "$OSNAME" in
- debian) FGC1="fgcolor 25";FGC2="fgcolor 253";FGC3="fgcolor 38";;
- arch) FGC1="fgcolor 24";FGC2="fgcolor 253";FGC3="fgcolor 239";;
- redhat|fedora) FGC1="fgcolor 88";FGC2="fgcolor 253";FGC3="fgcolor 203";;
- #*suse|aix) FGC1="fgcolor 22";FGC2="fgcolor 253";FGC3="fgcolor 41";;
- *sles*) FGC1="fgcolor 22";FGC2="fgcolor 253";FGC3="fgcolor 83";;
- *suse|aix) FGC1="fgcolor 30";FGC2="fgcolor 253";FGC3="fgcolor 83";;
- *centos*) FGC1="fgcolor 25";FGC2="fgcolor 253";FGC3="fgcolor 208";;
- *solaris) FGC1="fgcolor 31";FGC2="fgcolor 253";FGC3="fgcolor 124";;
- ubuntu) FGC1="fgcolor 130";FGC2="fgcolor 253";FGC3="fgcolor 215";;
- rasp*) FGC1="fgcolor 53";FGC2="fgcolor 253";FGC3="fgcolor 126";;
- rocky) FGC1="fgcolor 22";FGC2="fgcolor 253";FGC3="fgcolor 41";;
- *) FGC1="fgcolor 240";FGC2="fgcolor 253";FGC3="fgcolor 244";;
+ debian)
+ if [ "$OSMAJVER" -ge 12 ];then
+ FGC1="fgtcolor 155 15 64";FGC3="fgcolor 36"
+ else
+ FGC1="fgtcolor 155 15 64";FGC3="fgcolor 38"
+ fi
+ ;;
+ arch) FGC1="fgcolor 24";FGC3="fgcolor 239";;
+ redhat|rhel) FGC1="fgcolor 23";FGC3="fgcolor 88";;
+ fedora) FGC1="fgcolor 88";FGC3="fgcolor 203";;
+ #*suse|aix) FGC1="fgcolor 22";FGC3="fgcolor 41";;
+ *sles*) FGC1="fgcolor 22";FGC3="fgcolor 83";;
+ *suse*)
+ case "$OSNAME" in
+ *leap) FGC1="fgcolor 214";FGC3="fgcolor 83";;
+ *) FGC1="fgcolor 30";FGC3="fgcolor 83";;
+ esac
+ ;;
+ aix) FGC1="fgcolor 238";FGC3="fgcolor 83";;
+ *centos*) FGC1="fgcolor 25";FGC3="fgcolor 208";;
+ *solaris) FGC1="fgcolor 63";FGC3="fgcolor 124";;
+ ubuntu)
+ if [ "$OSMAJVER" -ge 24 ];then
+ if printf "%b" "$TERM"|grep -E 'xterm|256' > /dev/null;then
+ FGC1="fgcolor 125";FGC3="fgcolor 202"
+ else
+ FGC1="fgcolor 53";FGC3="fgcolor 184"
+ fi
+ elif [ "$OSMAJVER" -ge 22 ];then
+ if printf "%b" "$TERM"|grep -E 'xterm|256' > /dev/null;then
+ FGC1="fgcolor 89";FGC3="fgcolor 208"
+ else
+ FGC1="fgcolor 53";FGC3="fgcolor 184"
+ fi
+ else
+ FGC1="fgcolor 130";FGC3="fgcolor 215"
+ fi
+ ;;
+ rasp*) FGC1="fgcolor 52";FGC3="fgcolor 125";;
+ rocky) FGC1="fgcolor 240";FGC3="fgcolor 41";;
+ alma*) FGC1="fgcolor 124";FGC2="fgcolor 229";FGC3="fgcolor 39";;
+ sunos) FGC1="fgcolor 75";FGC3="fgcolor 130";;
+ nobara) FGC1="fgcolor 63";FGC3="fgcolor 133";;
+ *) FGC1="fgcolor 240";FGC3="fgcolor 244";;
esac
+ if [ -n "$TERMUX_APK_RELEASE" ]; then
+ if [ "$TERMUX_APK_RELEASE" == "F_DROID" ]; then
+ FGC1="fgcolor 27";FGC3="fgcolor 35"
+ fi
+ fi
;;
esac
+# HYPERVISOR LAYER 8 SOFTWARE
+if pveversion > /dev/null 2>&1;then
+ FGC1="fgcolor 238";FGC3="fgcolor 130"
+fi
# make it possible to draw user-defined colours
-# shellcheck disable=SC1090
+# shellcheck disable=SC1090,SC1091
[ -r "${BBD}/prompt.bash.local" ] && source "${BBD}/prompt.bash.local"
# ----- USER SEP. AND HOSTNAME ----- #
UHSEP="@"
[ -n "$TMUX_PANE" ]&&UHSEP="[T]"
[ -n "$BYOBU_WINDOW_NAME" ]&&UHSEP="[B]"
-[ "$(hostname -s)" == "monitoring" ]&&PHN="$(hostname -f)"||PHN="$(hostname -s)"
+[ "$OSNAME" != 'sunos' ]&&[ "$(hostname -s)" == "monitoring" ]&&PHN="$(hostname -f)"||PHN="$(hostname -s)"
# ----- ASSEMBLE THE PROMPT COMMAND ADDITION ----- #
__prompt_command() {
@@ -70,15 +157,52 @@ __prompt_command() {
else
local EXIT2="$EXIT"
fi
+ PS1='\[\033[2m\033[3m\]\#\[\033[0m\] '
+ if [ "$OSVER" ]; then
+ PS1+='\[\033[48;5;237m\033[\033[38;5;253m\] '
+ PS1+="$OSVER"
+ PS1+=' \[\033[0m\] '
+ fi
+ PS1+='\[\033[1m\]\['
+ PS1+="$($FGC1)"
+ PS1+='\]'
case "$MYUID" in
0)
- PS1="\\# \[$(tput bold)\]\[$($FGC1)\]\\u\[$($FGC2)\]@$PHN \[$($FGC3)\]\\w \[$(tput sgr0)\]"
+ # PS1="\[\\033[2m\\033[3m\]\\#\[\\033[0m\] \[$(tput bold)\]\[$($FGC1)\]\\u\[$($FGC2)\]@$PHN \[$($FGC3)\]\\w \[$(tput sgr0)\]\\n"
+ PS1+='\u\['
+ PS1+="($FGC2)"
+ PS1+='\]'
+ PS1+="@$PHN"
+ PS1+='\['
+ PS1+="$($FGC3)"
+ PS1+='\]\w \[\033[0m\]\n'
;;
*)
- PS1="\\# \[$(tput bold)\]\[$($FGC1)\]\t \[$($FGC2)\]\\u$UHSEP\[$($FGC3)\]$PHN \\w \[$(tput sgr0)\]"
+ # PS1="\[\\033[2m\\033[3m\]\\#\[\\033[0m\] \[$(tput bold)\]\[$($FGC1)\]\t \[$($FGC2)\]\\u$UHSEP\[$($FGC3)\]$PHN \\w \[$(tput sgr0)\]\\n"
+ PS1+='\t \['
+ PS1+="$($FGC2)"
+ PS1+='\]\u'
+ PS1+="$UHSEP"
+ PS1+='\['
+ PS1+="$($FGC3)"
+ PS1+='\]'
+ PS1+="$PHN"
+ PS1+=' \w \[\033[0m\]\n'
;;
esac
- if command -v __git_ps1 >/dev/null 2>&1;then PS1+="$(__git_ps1 "%s ")";fi
+ # git-completion. Sources:
+ # - https://github.com/git/git/tree/master/contrib/completion (main)
+ # - https://github.com/felipec/git-completion (fork)
+ # - Debian: easygit (outdated! you may want to use something like /git-prompt inside this repo)
+ # - Arch: git-completion (AUR, with functionality tests) - search for ...share/git(-completion)?/prompt.sh
+ # - Manual measure: this repository, /git-prompt
+ # Why all this fuss? magicmonty takes control over the whole prompt, __git_ps1 only serves a part
+ # of it. We don't like monoliths, we like modules; the latter is good practice.
+ # also, see postexec --> one-time sourcing of git's prompt.sh
+ if command -v __git_ps1 >/dev/null 2>&1;then
+ GIT_PS1_SHOWCOLORHINTS=1; export GIT_PS1_SHOWCOLORHINTS
+ PS1+="$(__git_ps1 "%s ")"
+ fi
if [ "$EXIT" -eq 0 ];then
PS1+="\[\033[0;32m\]# "
elif [ "$EXIT" -eq 255 ]||[ "$EXIT" -eq 127 ];then
diff --git a/.bash/vars.bash b/.bash/vars.bash
index cb124be..3bc68cd 100644
--- a/.bash/vars.bash
+++ b/.bash/vars.bash
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
# vim:syntax=sh
+# shellcheck disable=SC2034,SC1091
# default Byobu session name
export BSNAME="CHANGEME"
@@ -9,8 +10,6 @@ export SCRSHDIR="${HOME}/Pictures"
export SSHHOME="${HOME}/.ssh"
# 1. key files, array:
SSHKEYS=( "${SSHHOME}/id_ed25519" "${SSHHOME}/id_rsa" )
-# 2. SSH environment file
-export SSHENVFILE="${HOME}/.ssh/sshenv"
# 3. Hosts on which ssh-agent should run, FQDN. Array.
# Typically, "hosts" will equal your workstations. See ssh_config(5) (esp. ForwardAgent)
# Interpreted by fgrep / grep -F.
@@ -19,18 +18,28 @@ SSHAGH+=( "woschd.example.com" )
export SSHAGH
# ----- SHELL ----- #
-for pa in "/usr/local/bin" "${HOME}/bin";do
- if ! printf "%b" "$PATH"|grep -P "^${pa}:|:${pa}:" >/dev/null;then
- export PATH="${pa}:${PATH}"
+for pa in "/usr/local/bin" "${HOME}/bin" "${HOME}/.local/bin" "${HOME}/go/bin";do
+ if [ -x "$pa" ]; then
+ if ! printf "%b" "$PATH"|grep -E "^${pa}:|:${pa}:" >/dev/null;then
+ export PATH="${pa}:${PATH}"
+ fi
fi
done
# $OSNAME
if [ -r "/etc/os-release" ];then
- OSNAME="$(grep ^ID /etc/os-release|awk -F= '{print $NF}'|head -n1)"
+ OSNAME="$(grep ^ID /etc/os-release|awk -F= '{print $NF}'|head -n1|sed 's/"//g')"
+ if grep '^DEBIAN_VERSION_FULL' /etc/os-release >/dev/null 2>&1; then
+ OSVER="$(grep '^DEBIAN_VERSION_FULL' /etc/os-release|awk -F= '{print $NF}'|head -n1|sed 's/"//g')"
+ elif grep '^BUILD_ID' /etc/os-release >/dev/null 2>&1; then
+ OSVER="$(grep '^BUILD_ID' /etc/os-release|awk -F= '{print $NF}'|head -n1|sed 's/"//g')"
+ else
+ OSVER="$(grep '^VERSION_ID' /etc/os-release|awk -F= '{print $NF}'|head -n1|sed 's/"//g')"
+ fi
+elif [ "$(uname -s)" == 'SunOS' ]; then OSNAME="sunos"
elif [ -r "/etc/redhat-release" ];then
- grep -P "^Red[\ ]?[Hh]at" /etc/redhat-release >/dev/null 2>&1 && OSNAME="redhat"
- grep -P "^[Ff]edora" /etc/redhat-release >/dev/null 2>&1 && OSNAME="fedora"
- grep -P "^[Cc]ent[Oo][Ss]" /etc/redhat-release >/dev/null 2>&1 && OSNAME="centos"
+ grep -E "^Red[\ ]?[Hh]at" /etc/redhat-release >/dev/null 2>&1 && OSNAME="redhat"
+ grep -E "^[Ff]edora" /etc/redhat-release >/dev/null 2>&1 && OSNAME="fedora"
+ grep -E "^[Cc]ent[Oo][Ss]" /etc/redhat-release >/dev/null 2>&1 && OSNAME="centos"
[ -z "$OSNAME" ]&&OSNAME="obsolete"
elif [ -r "/etc/SuSE-release" ];then
OSNAME="oldsuse"
@@ -81,3 +90,13 @@ export LIBVIRT_DEFAULT_URI="qemu:///system"
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
+
+if [ -r "vars.bash.local" ];then
+ source vars.bash.local
+fi
+# SSH environment file
+#!/usr/bin/env bash
+# vim:syntax=sh
+#if echo "${SSHAGH[@]}" | grep -F --word-regexp "$(hostname -f)" > /dev/null;then
+ export SSHENVFILE="${HOME}/.ssh/sshenv"
+#fi