feat(console): adapt some scripts for termux

This commit is contained in:
Pavel Korytov 2023-01-30 22:50:09 +03:00
parent 49398d4cb8
commit 87626e0539
3 changed files with 26 additions and 12 deletions

View file

@ -1,5 +1,5 @@
# [[file:../../Console.org::*Fish][Fish:1]]
if [ "$TERM" != "dumb" ]
if [ "$TERM" != "dumb" ]; and type -q starship
starship init fish | source
end
# Fish:1 ends here
@ -20,7 +20,7 @@ alias cad="conda activate (basename (pwd))"
# Fish:2 ends here
# [[file:../../Console.org::*Fish][Fish:3]]
if ! test -n "$TMUX"; and ! test -n "$IS_EMACS";
if ! test -n "$TMUX"; and ! test -n "$IS_EMACS"; and type -q colorscript
colorscript random
end
# Fish:3 ends here

View file

@ -432,7 +432,7 @@ init_yc () {
Launch starship
#+begin_src fish
if [ "$TERM" != "dumb" ]
if [ "$TERM" != "dumb" ]; and type -q starship
starship init fish | source
end
#+end_src
@ -452,7 +452,7 @@ alias cad="conda activate (basename (pwd))"
Launch a random [[https://gitlab.com/dwt1/shell-color-scripts][DT's colorscript]] unless ran inside tmux or Emacs.
#+begin_src fish
if ! test -n "$TMUX"; and ! test -n "$IS_EMACS";
if ! test -n "$TMUX"; and ! test -n "$IS_EMACS"; and type -q colorscript
colorscript random
end
#+end_src
@ -894,9 +894,16 @@ PUSHED="No"
FETCHED="No"
MERGED="No"
notify () {
if command -v notify-send; then
notify-send -u ${LEVEL:-normal} "$1" "$2"
else
echo "$1" "$2"
fi
}
if [[ $(git ls-files -u | wc -l) -gt 0 ]]; then
notify-send -u critical "Autocommit $(pwd)" "Merge conflict!"
exit
LEVEL=critical notify "Autocommit $(pwd)" "Merge conflict!"
fi
if [[ ($RECENTLY_CHANGED_NUM -eq 0 || $2 = "-F") && $CHANGED_NUM -gt 0 ]]; then
@ -932,11 +939,11 @@ Fetched: $FETCHED
Merged: $MERGED
Pushed: $PUSHED
EOM
notify-send "Autocommit $(pwd)" "$NOTIFICATION"
notify "Autocommit $(pwd)" "$NOTIFICATION"
fi
if [[ $(git ls-files -u | wc -l) -gt 0 ]]; then
notify-send -u critical "Autocommit $(pwd)" "Merge conflict!"
LEVEL=critical notify "Autocommit $(pwd)" "Merge conflict!"
fi
#+end_src

View file

@ -14,9 +14,16 @@ PUSHED="No"
FETCHED="No"
MERGED="No"
notify () {
if command -v notify-send; then
notify-send -u ${LEVEL:-normal} "$1" "$2"
else
echo "$1" "$2"
fi
}
if [[ $(git ls-files -u | wc -l) -gt 0 ]]; then
notify-send -u critical "Autocommit $(pwd)" "Merge conflict!"
exit
LEVEL=critical notify "Autocommit $(pwd)" "Merge conflict!"
fi
if [[ ($RECENTLY_CHANGED_NUM -eq 0 || $2 = "-F") && $CHANGED_NUM -gt 0 ]]; then
@ -52,10 +59,10 @@ Fetched: $FETCHED
Merged: $MERGED
Pushed: $PUSHED
EOM
notify-send "Autocommit $(pwd)" "$NOTIFICATION"
notify "Autocommit $(pwd)" "$NOTIFICATION"
fi
if [[ $(git ls-files -u | wc -l) -gt 0 ]]; then
notify-send -u critical "Autocommit $(pwd)" "Merge conflict!"
LEVEL=critical notify "Autocommit $(pwd)" "Merge conflict!"
fi
# =autocommit=:1 ends here