bin: enhanced scripts

This commit is contained in:
xeruf 2023-10-04 17:17:06 +02:00
parent da7d70ebd0
commit 5157e2aacf
6 changed files with 37 additions and 14 deletions

View File

@ -1,27 +1,46 @@
set -o pipefail set -o pipefail
alias localip="ip addr show | grep -E '(ens|eth)' | grep -oP '"'(?<=inet\s)\d+(\.\d+){3}'"' | head -1"
letsencrypt() {
(
ip=$(localip)
IFS=$'\n'
for user in $(list users)
do for domain in $(hestia v-list-web-domains $user | grep $ip | awk '{print $1}')
do #echo "Checking $user $domain" >&2
hestia v-list-web-domain-ssl $user $domain | grep -q . && continue
hestia v-list-web-domain $user $domain | grep -q REDIRECT && continue
#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 ' ' ',')
done
done
)
}
list() { list() {
type="$1" type="$1"
shift shift
if test $# -eq 0 && echo $type | grep -q -- '-domains$' if test $# -eq 0 && echo $type | grep -q -- '-domains$'
then for user in $(list users) then for user in $(list users)
do test -t 1 && echo "$user" do if test -t 1
list "$type" "$user" then echo "$user" && list "$type" "$user"
else list "$type" "$user" | sed "s|^|$user |"
fi
done done
else if test -t 1 else if test -t 1
then sudo "/usr/local/hestia/bin/v-list-$type" "$@" | column -t then sudo "$HESTIA/bin/v-list-$type" "$@" | column -t
else sudo "/usr/local/hestia/bin/v-list-$type" "$@" | tail +3 | awk '{print $1}' else sudo "$HESTIA/bin/v-list-$type" "$@" | tail +3 | awk '{print $1}'
fi fi
fi fi
} }
hestia() { hestia() {
test $# -eq 0 && cd /usr/local/hestia && return 0 test $# -eq 0 && cd "$HESTIA" && return 0
set -x
command=$1 command=$1
shift shift
echo '>' sudo $(which $command) "$@" >&2
sudo $(which $command) "$@" sudo $(which $command) "$@"
set +x
} }
accessible() { accessible() {

View File

@ -142,8 +142,9 @@
ap = add -p ap = add -p
c = commit -v c = commit -v
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
cme = commit -v --edit --message # Commit with message but edit it cap = !git commit --amend --no-edit && git push --force-with-lease
cp = cherry-pick cp = cherry-pick
cpc = cherry-pick --continue cpc = cherry-pick --continue
@ -181,7 +182,6 @@
ruu = !git fetch upstream && git reset --keep upstream/${1:-$(git curbranch)} && git push --no-verify --force-with-lease ruu = !git fetch upstream && git reset --keep upstream/${1:-$(git curbranch)} && git push --no-verify --force-with-lease
luu = !git pull upstream ${1:-$(git curbranch)} && git push --no-verify luu = !git pull upstream ${1:-$(git curbranch)} && git push --no-verify
pf = push --force-with-lease pf = push --force-with-lease
cap = !git commit --amend --no-edit && git push --force-with-lease
# CLEANUP # CLEANUP
gcr = !git gc && git repack -a -d gcr = !git gc && git repack -a -d

View File

@ -419,7 +419,7 @@ hex() { hexyl "$@" | "${PAGER:-less}"; }
export DICT="$XDG_DATA_HOME/dictcc" export DICT="$XDG_DATA_HOME/dictcc"
dic() { dic() {
result=$(cat $DICT/dict.txt | sed '/#/d;/&/d;/^$/d' | FZF_DEFAULT_OPTS=${FZF_DEFAULT_OPTS#--exit-0} fzf --tiebreak=chunk,length --bind='alt-bspace:clear-query' --print-query --query="$1") && result=$(cat $DICT/dict.txt | sed '/#/d;/&/d;/^$/d' | FZF_DEFAULT_OPTS=${FZF_DEFAULT_OPTS#--exit-0} fzf --tiebreak=chunk,length --bind='alt-bspace:clear-query' --print-query --query="$1") &&
dic "$(echo "$result" | tail -1 | sed 's/\t/\n/g' | head -2 | grep --invert-match --ignore-case "$(echo "$result" | head -1)" --max-count 1 || echo "$result" | head -1 | sed 's/ \W.*//')" dic "$(echo "$result" | tail -1 | sed 's/\t/\n/g' | head -2 | grep --fixed-strings --invert-match --ignore-case "$(echo "$result" | head -1)" --max-count 1 || echo "$result" | head -1 | sed 's/ \W.*//')"
# Could be slightly improved using fzf -f to reproduce selection # Could be slightly improved using fzf -f to reproduce selection
} }
#fzf --tiebreak=length --bind='alt-bspace:clear-query' #fzf --tiebreak=length --bind='alt-bspace:clear-query'

View File

@ -1,6 +1,7 @@
# assign [app_id="firefox"] workspace 2 # assign [app_id="firefox"] workspace 2
assign [class="sc.gui.final.FinalApp"] workspace 5 assign [class="sc.gui.final.FinalApp"] workspace 5
assign [title="JViewer.*"] workspace 5 assign [title="JViewer.*"] workspace 5
assign [class="sc.*"] workspace 6
assign [class="discord"] workspace 9 assign [class="discord"] workspace 9
exec swaymsg "workspace 2; exec firefox;" exec swaymsg "workspace 2; exec firefox;"

View File

@ -6,7 +6,7 @@
# TODO fails on "Alchemy" # TODO fails on "Alchemy"
# TODO implement finding by tags # TODO implement finding by tags
PLAYLISTS="${PLAYLISTS:-$MUSIC/Playlists}" PLAYLISTS="${PLAYLISTS:-$MUSIC/Playlists}"
mpc -q clear mpc -q clear || mpdr && mpc -q clear
if test -z "$1" if test -z "$1"
then mp -q "$PLAYLISTS/focus.m3u" then mp -q "$PLAYLISTS/focus.m3u"
else else

3
.local/bin/scripts/way-row Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
way-displays -s ARRANGE_ALIGN ROW bottom
way-displays -s ORDER "$@"