config: script enhancements

This commit is contained in:
xeruf 2023-11-04 19:12:48 +01:00
parent 289c583fbe
commit 91d3180a7b
9 changed files with 53 additions and 26 deletions

View File

@ -3,19 +3,28 @@ set -o pipefail
alias localip="ip addr show | grep -E '(ens|eth)' | grep -oP '"'(?<=inet\s)\d+(\.\d+){3}'"' | head -1" alias localip="ip addr show | grep -E '(ens|eth)' | grep -oP '"'(?<=inet\s)\d+(\.\d+){3}'"' | head -1"
letsencrypt() { letsencrypt() {
if test $# -eq 0
then
for user in $(list users)
do letsencrypt "$user"
done
else
( (
ip=$(localip) ip=$(localip)
IFS=$'\n' IFS=$'\n'
for user in $(list users) for user
do for domain in $(hestia v-list-web-domains $user | grep $ip | awk '{print $1}') do for domain in $(hestia v-list-web-domains $user | grep $ip | awk '{print $1}')
do #echo "Checking $user $domain" >&2 do #echo commented out due to command echoing in hestia alias
hestia v-list-web-domain-ssl $user $domain | grep -q . && continue #echo "Checking $user $domain" >&2
hestia v-list-web-domain $user $domain | grep -q REDIRECT && continue hestia v-list-web-domain $user $domain | grep -q REDIRECT && continue
hestia v-list-mail-domain-ssl $user $domain | grep -q . || hestia v-add-letsencrypt-domain $user $domain '' yes
hestia v-list-web-domain-ssl $user $domain | grep -q . && continue
#echo "Generating Certificate" >&2 #echo "Generating Certificate" >&2
hestia v-add-letsencrypt-domain $user $domain $(hestia v-list-web-domain $user $domain | grep ALIAS | tr -s ' ' | cut -d' ' -f2- | tr ' ' ',') hestia v-add-letsencrypt-domain $user $domain $(hestia v-list-web-domain $user $domain | grep ALIAS | tr -s ' ' | cut -d' ' -f2- | tr ' ' ',')
done done
done done
) )
fi
} }
list() { list() {
@ -40,7 +49,7 @@ hestia() {
command=$1 command=$1
shift shift
echo '>' sudo $(which $command) "$@" >&2 echo '>' sudo $(which $command) "$@" >&2
sudo $(which $command) "$@" sudo timeout 30s $(which $command) "$@"
} }
accessible() { accessible() {

View File

@ -145,6 +145,7 @@
cme = commit -v --edit --message # Commit with message from CLI but edit it cme = commit -v --edit --message # Commit with message from CLI but edit it
cad = !git diff-tree --no-commit-id --name-only -r HEAD | git commit -v --amend --pathspec-from-file=- # Amend commit with all already changed files cad = !git diff-tree --no-commit-id --name-only -r HEAD | git commit -v --amend --pathspec-from-file=- # Amend commit with all already changed files
cap = !git commit --amend --no-edit && git push --force-with-lease cap = !git commit --amend --no-edit && git push --force-with-lease
journal = !git -C $DATA commit -v $DATA/2-box/journal*
cp = cherry-pick cp = cherry-pick
cpc = cherry-pick --continue cpc = cherry-pick --continue

View File

@ -27,7 +27,8 @@ if beginswith $'\n#' "$original"; then
expr substr "$common" 1 "$count" | sed 's|.local/bin/scripts|bin|') || exit 0 expr substr "$common" 1 "$count" | sed 's|.local/bin/scripts|bin|') || exit 0
case "$path" in ([0-9]-*) path="${path#*-}";; esac case "$path" in ([0-9]-*) path="${path#*-}";; esac
{ {
echo "$path" | sed 's|^\.||;s|/\?$|: |' # Remove initial dot and trailing slash/dash/underscore
echo "$path" | sed 's|^\.||;s|[/_-]\?$|: |'
echo "$original" echo "$original"
} > "$COMMIT_MSG_FILE" } > "$COMMIT_MSG_FILE"
fi fi

View File

@ -11,8 +11,9 @@ highlight: true
indent_character: '|' indent_character: '|'
journals: journals:
default: ~/data/2-box/journal/jrnl.txt default: ~/data/2-box/journal/jrnl.txt
tug: ~/data/2-box/journal/tug.txt
nug: ~/data/2-box/journal/nuggets.txt
intentions: ~/data/2-box/journal/intentions.txt intentions: ~/data/2-box/journal/intentions.txt
nug: ~/data/2-box/journal/nug.txt
linewrap: 99 linewrap: 99
tagsymbols: '@' tagsymbols: '@'
template: false template: false

View File

@ -37,11 +37,14 @@ let g:firenvim_config = {
\ '.*calendar\.google\.com.*': { 'priority': 9, 'takeover': 'empty', }, \ '.*calendar\.google\.com.*': { 'priority': 9, 'takeover': 'empty', },
\ '.*docs\.google\.com.*': { 'priority': 9, 'takeover': 'never', }, \ '.*docs\.google\.com.*': { 'priority': 9, 'takeover': 'never', },
\ '.*contacts\.google\.com.*': { 'priority': 9, 'takeover': 'never', }, \ '.*contacts\.google\.com.*': { 'priority': 9, 'takeover': 'never', },
\ '.*notion\.so.*': { 'priority': 9, 'takeover': 'never', },
\ '.*cloud\.atomtoast\.xyz.*': { 'priority': 9, 'takeover': 'never', }, \ '.*cloud\.atomtoast\.xyz.*': { 'priority': 9, 'takeover': 'never', },
\ 'https://bigbluebutton.*': { 'priority': 9, 'takeover': 'never', }, \ '://notion\.so.*': { 'priority': 9, 'takeover': 'never', },
\ 'https://dhall-lang.org.*': { 'priority': 9, 'takeover': 'never', }, \ '://bbb\..*': { 'priority': 9, 'takeover': 'never', },
\ 'https://aur.archlinux.org/account.*': { 'priority': 9, 'takeover': 'never', }, \ '://bigbluebutton.*': { 'priority': 9, 'takeover': 'never', },
\ '://dhall-lang.org.*': { 'priority': 9, 'takeover': 'never', },
\ '://aur.archlinux.org/account.*': { 'priority': 9, 'takeover': 'never', },
\ '.*\.hobbyfarm\..*': { 'priority': 9, 'takeover': 'never', },
\ '://rancher\..*': { 'priority': 9, 'takeover': 'never', },
\ \
\ '.*stackexchange\.com.*': { 'priority': 9, 'takeover': 'never', }, \ '.*stackexchange\.com.*': { 'priority': 9, 'takeover': 'never', },
\ '.*stackoverflow\.com.*': { 'priority': 9, 'takeover': 'never', }, \ '.*stackoverflow\.com.*': { 'priority': 9, 'takeover': 'never', },

View File

@ -246,7 +246,7 @@ alias dt='python -c "import time;print(time.asctime(time.localtime()))"'
# Process # Process
alias println='printf "\n"' alias println='printf "\n"'
alias myip="curl ifconfig.me && println && curl icanhazip.com" alias myip="curl ifconfig.me && println && curl icanhazip.com"
alias dedup='awk '"'"'!a[$0]++'"'" alias dedup-lines='awk '"'"'!a[$0]++'"'"
alias lar='last | tac' alias lar='last | tac'
alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G' alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G'
alias hedgedoc="tmux kill-session -t hedgedoc; builtin cd '$d4/dev/_forks/hedgedoc' && tmux new-session -s hedgedoc -d 'yarn run dev' \; split-window -h 'nodemon --watch app.js --watch lib --watch locales --watch config.json app.js' \; ls" alias hedgedoc="tmux kill-session -t hedgedoc; builtin cd '$d4/dev/_forks/hedgedoc' && tmux new-session -s hedgedoc -d 'yarn run dev' \; split-window -h 'nodemon --watch app.js --watch lib --watch locales --watch config.json app.js' \; ls"
@ -329,11 +329,12 @@ sshl() {
ssh -G "$1" | grep --silent "^user root$" && ssh -G "$1" | grep --silent "^user root$" &&
! [[ "$1" =~ "pve.*" ]] && ! [[ "$1" =~ "pve.*" ]] &&
! [[ "$1" =~ "encee.*" ]] && ! [[ "$1" =~ "encee.*" ]] &&
! [[ "$1" =~ ".*fmh.*" ]] && ! [[ "$1" =~ ".*ofc.*" ]] &&
! [[ "$1" =~ "delta*" ]] && ! [[ "$1" =~ "delta*" ]] &&
! [[ "$1" =~ "tmtgw" ]] &&
local pass=pass local pass=pass
test "$all" && test "$all" &&
find $XDG_CONFIG_HOME/bash/ \( -name aliases.bash -o -name "$1*.bash" \) -exec cat {} + | $pass ssh "$1" 'cat > .bash_aliases && grep -q .bash_aliases .bashrc || echo "source ~/.bash_aliases" | tee -a .bashrc' && find $XDG_CONFIG_HOME/bash/ \( -name aliases.bash -o -name "${1%[0-9a-z]}*.bash" \) -exec cat {} + | $pass ssh "$1" 'cat > .bash_aliases && grep -q .bash_aliases .bashrc || echo "source ~/.bash_aliases" | tee -a .bashrc' &&
echo 'Updated .bash_aliases!' echo 'Updated .bash_aliases!'
#$pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc' #$pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc'
if test -n "$pass" if test -n "$pass"
@ -410,7 +411,7 @@ vrec() {
alias vrecd="ls $XDG_DATA_HOME/nvim/swap | head -1 | xargs -r -i mv {} /tmp" alias vrecd="ls $XDG_DATA_HOME/nvim/swap | head -1 | xargs -r -i mv {} /tmp"
# I think this was something about recovering backup files # I think this was something about recovering backup files
unv() { strings $1 | sed 's/5$//' | dedup; } unv() { strings $1 | sed 's/5$//' | dedup-lines; }
alias hx='sudo hexedit --maximize --color' alias hx='sudo hexedit --maximize --color'
# Paginated hexyl # Paginated hexyl
@ -641,3 +642,14 @@ stopswap() {
echo "Not enough free memory!" echo "Not enough free memory!"
fi fi
} }
extrac() {
for var; do
arg=${var%.lzo}
out=$(basename ${arg%.vma})
lzop -x $arg.lzo
vma.py $arg $out ||
vma.py $(basename $arg) $out &&
( cd $out && find *.raw -exec qemu-img convert {} -O qcow2 $out-{}.qcow2 \; )
done
}

View File

@ -58,7 +58,7 @@ arguments = "--rebase --autostash --recurse-submodules"
[linux] [linux]
# Arguments to pass yay when updating packages # Arguments to pass yay when updating packages
yay_arguments = "--nodiffmenu --ignore android-studio --ignore clion --ignore intellij-idea-ultimate-edition --ignore intellij-idea-ultimate-edition-jre --ignore webstorm --ignore linux --ignore stretchly-xeruf-git --overwrite '/usr/lib/node_modules/npm/**'" yay_arguments = "--nodiffmenu --overwrite '/usr/lib/node_modules/npm/**' --overwrite '/usr/lib/*' --ignore android-studio --ignore clion --ignore intellij-idea-ultimate-edition --ignore intellij-idea-ultimate-edition-jre --ignore webstorm --ignore linux --ignore stretchly-xeruf-git"
#trizen_arguments = "--devel" #trizen_arguments = "--devel"
#enable_tlmgr = true #enable_tlmgr = true
#emerge_sync_flags = "-q" #emerge_sync_flags = "-q"

View File

@ -10,7 +10,7 @@ XDG_TEMPLATES_DIR="$HOME/.local/templates"
XDG_DOWNLOAD_DIR="$HOME/data/5-incubator" XDG_DOWNLOAD_DIR="$HOME/data/5-incubator"
XDG_MUSIC_DIR="$HOME/data/4-media/music" XDG_MUSIC_DIR="$HOME/data/4-media/music"
XDG_PICTURES_DIR="$HOME/data/4-media/images" XDG_PICTURES_DIR="$HOME/data/4-media/images"
XDG_VIDEOS_DIR="$HOME/data/4-media/videos" XDG_VIDEOS_DIR="$HOME/data/4-media/video"
XDG_DOCUMENTS_DIR="$HOME/data/4-media/multimedia" XDG_DOCUMENTS_DIR="$HOME/data/4-media/multimedia"
XDG_NOTES_DIR="$HOME/data/2-box" XDG_NOTES_DIR="$HOME/data/2-box"
#XDG_PUBLICSHARE_DIR="$HOME/data/3-resources/multimedia" #XDG_PUBLICSHARE_DIR="$HOME/data/3-resources/multimedia"

View File

@ -100,7 +100,7 @@ export LS_OPTIONS='--color=auto --human-readable --si --group-directories-first
export LESS="--raw-control-chars --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)" export LESS="--raw-control-chars --ignore-case --LONG-PROMPT --jump-target=5 $(test $(less --version | head -1 | cut -f2 -d' ') -ge 590 && echo --incsearch)"
# TODO put into config file and use --exclude-from # TODO put into config file and use --exclude-from
# -x 'System Volume Information' # -x 'System Volume Information'
export DIRS_GENERATED="-x generated -x .gradle -x cmake_build -x dist-newstyle -x node_modules -x __pycache__" export DIRS_GENERATED="-x generated -x .gradle -x cmake_build -x dist-newstyle -x node_modules -x __pycache__ -x .pytest_cache"
export DIRS_IGNORE_SAFE="-x .cache -x .cpan -x *Cache -x .pyenv -x .local/cache -x share/baloo -x share/cabal -x share/cargo -x share/digikam -x share/gem -x share/JetBrains -x share/tldr -x share/syncthing -x share/Steam/ubuntu* -x share/Steam/package -x share/virtualenv -x share/Zeal -x state/gradle -x state/android -x Ferdi/Partitions -x oh-my-zsh -x wine/drive_c/windows -x vendor/cache $DIRS_GENERATED" export DIRS_IGNORE_SAFE="-x .cache -x .cpan -x *Cache -x .pyenv -x .local/cache -x share/baloo -x share/cabal -x share/cargo -x share/digikam -x share/gem -x share/JetBrains -x share/tldr -x share/syncthing -x share/Steam/ubuntu* -x share/Steam/package -x share/virtualenv -x share/Zeal -x state/gradle -x state/android -x Ferdi/Partitions -x oh-my-zsh -x wine/drive_c/windows -x vendor/cache $DIRS_GENERATED"
export DIRS_IGNORE="-x .sync -x .stfolder -x *build -x .git -x .idea -x env -x out -x cache -x Partitions -x vendor/bundle -x log $DIRS_IGNORE_SAFE" export DIRS_IGNORE="-x .sync -x .stfolder -x *build -x .git -x .idea -x env -x out -x cache -x Partitions -x vendor/bundle -x log $DIRS_IGNORE_SAFE"
# red stderr # red stderr
@ -148,7 +148,7 @@ FD_BASE="fd --hidden --color=always --no-ignore-vcs"
export FZF_DEFAULT_COMMAND="$FD_BASE --type file" export FZF_DEFAULT_COMMAND="$FD_BASE --type file"
export FZF_CTRL_T_COMMAND="$FD_BASE -d 7" export FZF_CTRL_T_COMMAND="$FD_BASE -d 7"
## cplusplus - ctest, cmake, ninja ## cplusplus - ctest, cmake, ninja
SPARE_CORES=$(expr $(lscpu --extended | awk '{print $7}' | sort | uniq -c | head -1 | awk '{print $1}') \* 4 / 5) export SPARE_CORES=$(expr $(lscpu --extended | awk '{print $7}' | sort | uniq -c | head -1 | awk '{print $1}') \* 2 / 3)
export CMAKE_BUILD_PARALLEL_LEVEL=${SPARE_CORES} export CMAKE_BUILD_PARALLEL_LEVEL=${SPARE_CORES}
export CTEST_PARALLEL_LEVEL=${SPARE_CORES} export CTEST_PARALLEL_LEVEL=${SPARE_CORES}
export CTEST_PROGRESS_OUTPUT=1 export CTEST_PROGRESS_OUTPUT=1