config/shell: function adjustments
This commit is contained in:
parent
e888d12fb9
commit
886b3b9172
|
@ -45,7 +45,7 @@ yas() {
|
|||
)
|
||||
if test -n "$pkg"
|
||||
then echo "Installing $pkg..."
|
||||
cmd="yay -Sy --batchinstall --rebuildtree $pkg"
|
||||
cmd="yay -Sy --batchinstall --rebuildall $pkg"
|
||||
print -s "$cmd"
|
||||
eval "$cmd"
|
||||
rehash
|
||||
|
|
|
@ -289,12 +289,12 @@ u() {
|
|||
fi
|
||||
if command -v topgrade >/dev/null
|
||||
then
|
||||
nice -10 topgrade --disable node emacs remotes
|
||||
nice -10 topgrade --disable node emacs remotes rustup nix
|
||||
if test -d "$XDG_CONFIG_HOME/emacs"
|
||||
then
|
||||
builtin cd $XDG_CONFIG_HOME/emacs
|
||||
git pull --rebase
|
||||
if ! true | doom sync -u
|
||||
if ! true | doom --force upgrade
|
||||
then echo "Rebuild doom from scratch?"
|
||||
read result
|
||||
test "$result" = "y" && rm -rf "$DOOMLOCALDIR/straight" && doom sync -u
|
||||
|
@ -342,8 +342,9 @@ sshl() {
|
|||
! [[ "$1" =~ "nc-*" ]] &&
|
||||
! [[ "$1" =~ "ddns*" ]] &&
|
||||
local pass=pass
|
||||
local target=${1%[0-9a-z]}
|
||||
test "$all" &&
|
||||
find $XDG_CONFIG_HOME/bash/ \( -name aliases.bash -o -name "${1%[0-9a-z]}*.bash" \) -exec cat {} + | $pass ssh "$@" '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 "${target#nc-}*.bash" \) -exec cat {} + | $pass ssh "$@" 'cat > .bash_aliases && grep -q .bash_aliases .bashrc || echo "source ~/.bash_aliases" | tee -a .bashrc' &&
|
||||
echo 'Updated .bash_aliases!'
|
||||
#$pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc'
|
||||
if test -n "$pass"
|
||||
|
@ -507,8 +508,11 @@ which exa >/dev/null &&
|
|||
alias ll='l --long --git --all'
|
||||
|
||||
if which fd >/dev/null 2>&1
|
||||
then fn() { $(command -v fd || echo fdfind) --hidden --no-ignore-vcs --one-file-system "$@" | less -F; } # [F]ind [n]o ignore
|
||||
alias ff="noglob fn --color=always " # [F]ind [F]ile
|
||||
then
|
||||
# [F]ind [n]o ignore
|
||||
fn() { $(command -v fd || echo fdfind) --hidden --no-ignore-vcs --one-file-system "$@" | less -F; }
|
||||
# [F]ind [F]ile
|
||||
alias ff="noglob fn --color=always "
|
||||
compdef ff=fd
|
||||
compdef fn=fd
|
||||
else
|
||||
|
|
|
@ -31,10 +31,10 @@ mozedit() (
|
|||
cat "$tmpfile2" | sed "$2" | lz4 -l | dd bs=1 skip=8 seek=12 of="$file" conv=notrunc
|
||||
)
|
||||
|
||||
test "$XDG_CURRENT_DESKTOP" = "KDE" || return 0
|
||||
|
||||
# Switch theme across system: KDE, Konsole, taskwarrior, bat
|
||||
# WIP: Emacs, Mozilla, diffr (git pager)
|
||||
# Switch theme across system: KDE, Konsole, taskwarrior, bat, diffr (git pager)
|
||||
# WIP: Emacs, Mozilla
|
||||
# TODO terminal tool themer https://www.linuxjournal.com/content/revolutionizing-command-line-interface-dynamic-themes
|
||||
# TODO bluetuith
|
||||
theme_save="$XDG_CACHE_HOME/theme"
|
||||
#theme_default="$(d=$(date +%H) && test $d -gt 7 && test $d -lt 19 && echo light || echo dark)"
|
||||
theme_default="dark"
|
||||
|
@ -44,35 +44,47 @@ themeswitch() {
|
|||
then kcmshell5 kcm_lookandfeel
|
||||
elif test "$theme" != "$THEME" -a "$2" != "q"
|
||||
then kcmshell5 kcm_lookandfeel &
|
||||
# TODO theme diffr rather than disabling it
|
||||
bak $XDG_CONFIG_HOME/git/diffr
|
||||
emacsclient -e "(toggle-theme \"$theme\")"
|
||||
fi
|
||||
# TODO kitty
|
||||
export THEME="$theme"
|
||||
echo "$theme">"$theme_save"
|
||||
|
||||
diffr="$XDG_CONFIG_HOME/git/diffr"
|
||||
ln -srf "$diffr-$theme" "$diffr"
|
||||
|
||||
#mozfile=$(find $HOME/.mozilla/firefox/ -maxdepth 2 -name addonStartup.json.lz4 | grep ".test")
|
||||
kitty="$XDG_CONFIG_HOME/kitty/theme.conf"
|
||||
case "$theme" in
|
||||
(light)
|
||||
alias ai='aichat --light-theme'
|
||||
# LESS_TERMCAP_DEBUG=true man man
|
||||
export LESS_TERMCAP_md=$'\e[1;34m' # bold blue
|
||||
export BAT_THEME="OneHalfLight"
|
||||
konsoleprofile colors="Light"
|
||||
#konsoleprofile colors="Light"
|
||||
ln -srf "$(dirname "$kitty")/theme-light.conf" "$kitty"
|
||||
#sed -i 's/#\(include.*\/light-256.theme\)/\1/' "$XDG_CONFIG_HOME/task/taskrc"
|
||||
#mozedit $mozfile '/light@mozilla/,/"enabled"/ s/\("enabled":.*\)false/\1true/; /dark@mozilla/,/"enabled"/ s/\("enabled":.*\)true/\1false/'
|
||||
;;
|
||||
(dark)
|
||||
alias ai=aichat
|
||||
export BAT_THEME="OneHalfDark"
|
||||
konsoleprofile colors="Breeze"
|
||||
#konsoleprofile colors="Breeze"
|
||||
rm -f "$kitty"
|
||||
#sed -i 's/^include.*light-256.theme/#\0/' "$XDG_CONFIG_HOME/task/taskrc"
|
||||
#mozedit $mozfile '/light@mozilla/,/"enabled"/ s/\("enabled":.*\)true/\1false/; /dark@mozilla/,/"enabled"/ s/\("enabled":.*\)false/\1true/'
|
||||
;;
|
||||
esac
|
||||
pkill --signal SIGUSR1 kitty
|
||||
}
|
||||
export THEME=$(cat "$theme_save" 2> /dev/null)
|
||||
export THEME=${THEME:-$theme_default}
|
||||
themeswitch $THEME
|
||||
alias ts='themeswitch'
|
||||
|
||||
alias ky='ai --role swahili'
|
||||
alias en='ai --role en'
|
||||
|
||||
test "$XDG_CURRENT_DESKTOP" = "KDE" || return 0
|
||||
|
||||
# Fix errors regarding broken mim database
|
||||
alias fixmime='sudo rm /usr/share/mime/packages/kde.xml && sudo update-mime-database /usr/share/mime'
|
||||
|
|
|
@ -45,7 +45,24 @@ stack() {
|
|||
#test "$PWD" = "$HOME" && builtin cd "$STACKSPIN"
|
||||
;;
|
||||
(activate)
|
||||
test -d "$STACKSPIN" && . $STACKSPIN/env/bin/activate
|
||||
test -d "$STACKSPIN" && . "$STACKSPIN/env/bin/activate"
|
||||
;;
|
||||
(setup) # https://docs.stackspin.net/en/latest/installation/install_cli.html
|
||||
cd "$STACKSPIN" &&
|
||||
python3 -m venv env &&
|
||||
"$0" activate
|
||||
;;
|
||||
(override)
|
||||
cd "$STACKSPIN/../stackspout/overrides"
|
||||
name=stackspin-$1-override
|
||||
echo "apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
namespace: stackspin-apps
|
||||
name: $name
|
||||
data:
|
||||
values.yaml: |" >"$name.yaml"
|
||||
$EDITOR "$name.yaml"
|
||||
;;
|
||||
(sso) "$cmdname" exec dashboard-backend -- flask "$@";;
|
||||
(users)
|
||||
|
@ -130,9 +147,13 @@ stack() {
|
|||
)
|
||||
;;
|
||||
(backup)
|
||||
if test $# -gt 0
|
||||
then velero "$@"
|
||||
else
|
||||
backupname=$(date +%y%m%d.%H%m)
|
||||
velero create backup $backupname --exclude-namespaces velero --wait
|
||||
velero backup logs $backupname;;
|
||||
velero backup logs $backupname
|
||||
fi;;
|
||||
(restore)
|
||||
if test $# -lt 2
|
||||
then echo "$0 $command <backup> <app> [namespace]"
|
||||
|
@ -189,7 +210,7 @@ stack() {
|
|||
# KUBE
|
||||
# app clis
|
||||
(occ) "$cmdname" exec nc-nextcloud -c nextcloud -it -- su www-data -s /bin/bash -c "php $command $*";;
|
||||
(zulip) "$cmdname" exec zulip -- su zulip -c "/home/zulip/deployments/current/manage.py $*";;
|
||||
(zulip) "$cmdname" exec zulip -- su zulip -c "/home/zulip/deployments/current/scripts/$* || /home/zulip/deployments/current/manage.py $*";;
|
||||
(vikunja*)
|
||||
local pod=$command
|
||||
case "$1" in
|
||||
|
@ -271,7 +292,8 @@ stack() {
|
|||
kubectl cp "$2" -n $("$cmdname" pod "$1$pod_suffix"):$2 "${@:3}"
|
||||
"$cmdname" ls "$1" "${@:3}";;
|
||||
(exec) "$cmdname" kube exec "$@";;
|
||||
(logs) podname=$1
|
||||
(logs) test $# -gt 0 || { echo "$0 $command <pod> [lnav-args...]"; return; }
|
||||
podname="$1"
|
||||
shift
|
||||
"$cmdname" kube logs "$podname" -f | $(command which ${LOGPAGER:-lnav} || { which bat >/dev/null && echo "bat --number -l toml" } || echo 'less -RF') "$@";;
|
||||
# low-level
|
||||
|
@ -299,6 +321,11 @@ stack() {
|
|||
return $code
|
||||
fi
|
||||
;;
|
||||
(clean-pods)
|
||||
kubectl get pods --all-namespaces --no-headers |
|
||||
egrep -iv 'PodInitializing|Running|ContainerCreating|Terminating' |
|
||||
awk '{print "--namespace=" $1 " " $2}' |
|
||||
xargs -L 1 kubectl delete pod;;
|
||||
# stackspin bare
|
||||
(*) if which "$cmdname-$command" >/dev/null 2>&1
|
||||
then "$cmdname-$command" "$@"
|
||||
|
|
Loading…
Reference in New Issue