diff --git a/completions/pipx.fish b/completions/pipx.fish new file mode 100644 index 0000000..79be035 --- /dev/null +++ b/completions/pipx.fish @@ -0,0 +1,17 @@ + +function __fish_pipx_complete + set -x _ARGCOMPLETE 1 + set -x _ARGCOMPLETE_DFS \t + set -x _ARGCOMPLETE_IFS \n + set -x _ARGCOMPLETE_SUPPRESS_SPACE 1 + set -x _ARGCOMPLETE_SHELL fish + set -x COMP_LINE (commandline -p) + set -x COMP_POINT (string length (commandline -cp)) + set -x COMP_TYPE + if set -q _ARC_DEBUG + pipx 8>&1 9>&2 1>&9 2>&1 + else + pipx 8>&1 9>&2 1>/dev/null 2>&1 + end +end +complete --command pipx -f -a '(__fish_pipx_complete)' diff --git a/config.fish b/config.fish index 1e09307..14d65d2 100644 --- a/config.fish +++ b/config.fish @@ -16,3 +16,8 @@ set -U "fish_color_operator" "cyan" set -U "fish_color_escape" "green" set -U "fish_color_autosuggestion" "brblack" set -U "fish_color_cancel" "white" "--background=brred" + +set -U "DOTFISH_LOG_LEVEL" "100" + +eval (ssh-agent -c) +ssh-add ~/.ssh/id_ed25519 diff --git a/functions/btm.fish b/functions/btm.fish index 3dc5f31..1927e24 100644 --- a/functions/btm.fish +++ b/functions/btm.fish @@ -1,3 +1,6 @@ -function btm --wraps="btm" - command btm --enable_gpu_memory $argv; +which btm --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function btm --wraps="btm" + command btm --enable_gpu_memory $argv; + end end diff --git a/functions/cls.fish b/functions/cls.fish index 6016bc4..f66e8c4 100644 --- a/functions/cls.fish +++ b/functions/cls.fish @@ -1,3 +1,6 @@ -function cls --wraps="clear" - clear $argv; +which clear --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function cls --wraps="clear" + command clear $argv + end end diff --git a/functions/cp.fish b/functions/cp.fish index 9a5736f..dfc9bb6 100644 --- a/functions/cp.fish +++ b/functions/cp.fish @@ -1,3 +1,6 @@ -function cp --wraps="cp" - command cp -i $argv; +which cp --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function cp --wraps="cp" + command cp --interactive --verbose $argv; + end end diff --git a/functions/dotfish.fish b/functions/dotfish.fish index e3700fc..3590054 100644 --- a/functions/dotfish.fish +++ b/functions/dotfish.fish @@ -4,40 +4,35 @@ function dotfish end for TARGET in $argv - echo_progress "Updating fish config for: " - echo_highlight "$TARGET" \n - + log-d "Updating fish config for:" "$TARGET" "" set -g FISHCONFIG ~(echo $TARGET)/.config/fish - echo_progress "Destination directory is: " - echo_highlight "$FISHCONFIG" \n - + log-d "Destination directory is:" "$FISHCONFIG" "" if not test -e "$FISHCONFIG/.DOTFISHED" - echo_progress "Conflicting config detected, confirm deletion?" \n + log-w "Conflicting config detected" "$FISHCONFIG" ", delete?" if confirm - echo_progress "Deleting old config..." \n - rm -rf "$FISHCONFIG" + log-d "Deleting old config at" "$FISHCONFIG" "..." + command rm -rf "$FISHCONFIG" else - echo_progress "Deletion was refused, skipping..." \n + log-d "Deletion rejected, not touching" "$FISHCONFIG" "..." continue end - end - + end if test -d "$FISHCONFIG" - echo_progress "Existing config detected, pulling from Git..." \n - git -C "$FISHCONFIG" pull + log-d "Existing config detected at" "$FISHCONFIG" "pulling from Git..." + command git -C "$FISHCONFIG" pull else - echo_progress "No config detected, cloning from Git..." \n - git clone "https://github.com/Steffo99/.config-fish" "$FISHCONFIG" + log-d "No config detected, cloning from Git into" "$FISHCONFIG" "..." + command git clone "https://github.com/Steffo99/.config-fish" "$FISHCONFIG" end - echo_progress "Fixing permissions..." \n - chown -R "$TARGET:" "$FISHCONFIG" + log-d "Fixing permissions at" "$FISHCONFIG" "..." + command chown -R "$TARGET:" "$FISHCONFIG" - echo_progress "Changing login shell..." \n - chsh -s "/usr/bin/fish" "$TARGET" + log-d "Changing login shell to" "/usr/bin/fish" "..." + command chsh -s "/usr/bin/fish" "$TARGET" - echo_progress "Update complete!" \n + log-s "" "Dotfish" "updated successfully!" end end \ No newline at end of file diff --git a/functions/dudo.fish b/functions/dudo.fish index 88fbbbf..b6a7f5e 100644 --- a/functions/dudo.fish +++ b/functions/dudo.fish @@ -1,3 +1,6 @@ -function dudo --wraps="sudo" - sudo $argv; +which sudo --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function dudo --wraps="sudo" + command sudo $argv + end end diff --git a/functions/echo_error.fish b/functions/echo_error.fish deleted file mode 100644 index 53f38c1..0000000 --- a/functions/echo_error.fish +++ /dev/null @@ -1,5 +0,0 @@ -function echo_error --wraps="echo" - set_color brred --bold - echo -n $argv - set_color normal -end \ No newline at end of file diff --git a/functions/echo_highlight.fish b/functions/echo_highlight.fish deleted file mode 100644 index c27b9b4..0000000 --- a/functions/echo_highlight.fish +++ /dev/null @@ -1,5 +0,0 @@ -function echo_highlight --wraps="echo" - set_color yellow - echo -n $argv - set_color normal -end \ No newline at end of file diff --git a/functions/echo_progress.fish b/functions/echo_progress.fish deleted file mode 100644 index 96b764a..0000000 --- a/functions/echo_progress.fish +++ /dev/null @@ -1,5 +0,0 @@ -function echo_progress --wraps="echo" - set_color yellow --dim - echo -n $argv - set_color normal -end \ No newline at end of file diff --git a/functions/emoji-akkoma.fish b/functions/emoji-akkoma.fish new file mode 100644 index 0000000..bb8c062 --- /dev/null +++ b/functions/emoji-akkoma.fish @@ -0,0 +1,10 @@ +which magick --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function emoji-akkoma --wraps=magick + log-d "Creating" "Akkoma" "directory..." + command mkdir --parents "Akkoma" + log-d "Processing" "$argv[1]" "..." + command magick -background none "$argv[1]" -resize "106x106^" -gravity center -extent 106x106 $argv[2..-1] "Akkoma/$argv[1]" + log-s "Done! Emojis added to the " "Akkoma" "directory!" + end +end diff --git a/functions/emoji-discord.fish b/functions/emoji-discord.fish new file mode 100644 index 0000000..0ba40c6 --- /dev/null +++ b/functions/emoji-discord.fish @@ -0,0 +1,10 @@ +which magick --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function emoji-discord --wraps=magick + log-d "Creating" "Discord" "directory..." + command mkdir --parents "Discord" + log-d "Processing" "$argv[1]" "..." + command magick -background none "$argv[1]" -resize "106x106^" -gravity center -extent 128x128 $argv[2..-1] "Discord/$argv[1]" + log-s "Done! Emojis added to the " "Discord" "directory!" + end +end diff --git a/functions/emoji-telegram.fish b/functions/emoji-telegram.fish new file mode 100644 index 0000000..75fe9cc --- /dev/null +++ b/functions/emoji-telegram.fish @@ -0,0 +1,10 @@ +which magick --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function emoji-telegram --wraps=magick + log-d "Creating" "Telegram" "directory..." + command mkdir --parents "Telegram" + log-d "Processing" "$argv[1]" "..." + command magick -background none "$argv[1]" -resize "100x100^" -gravity center -extent 128x128 $argv[2..-1] "Telegram/$argv[1]" + log-s "Done! Emojis added to the " "Telegram" "directory!" + end +end diff --git a/functions/idea.fish b/functions/idea.fish deleted file mode 100644 index d021319..0000000 --- a/functions/idea.fish +++ /dev/null @@ -1,3 +0,0 @@ -function idea --wraps="idea" - command idea -e -w $argv; -end diff --git a/functions/ll.fish b/functions/ll.fish index 87df0fc..c0593a2 100644 --- a/functions/ll.fish +++ b/functions/ll.fish @@ -1,3 +1,6 @@ -function ll --wraps="ls" - ls --all --author --color --kibibytes --human-readable -l $argv; +which ls --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function ll --wraps=ls + command ls --all --author --color --kibibytes --human-readable -l $argv; + end end diff --git a/functions/log-d.fish b/functions/log-d.fish new file mode 100644 index 0000000..a65887f --- /dev/null +++ b/functions/log-d.fish @@ -0,0 +1,18 @@ +function log-d + if [ $DOTFISH_LOG_LEVEL -lt 50 ] + return + end + + set_color blue + echo -n -- "$argv[1] " + set_color normal + + set_color --bold brblue + echo -n -- "$argv[2]" + set_color normal + + set_color blue + echo -n -- " $argv[3]" + echo + set_color reset +end diff --git a/functions/log-demo.fish b/functions/log-demo.fish new file mode 100644 index 0000000..9471d7a --- /dev/null +++ b/functions/log-demo.fish @@ -0,0 +1,9 @@ +function log-demo + log-t "This is a" "TRACE (60)" "log." + log-d "This is a" "DEBUG (50)" "log." + log-i "This is a" "INFORMATION (40)" "log." + log-s "This is a" "SUCCESS (30)" "log." + log-w "This is a" "WARNING (20)" "log." + log-e "This is a" "ERROR (10)" "log." + log-f "This is a" "FATAL (0)" "log." +end \ No newline at end of file diff --git a/functions/log-e.fish b/functions/log-e.fish new file mode 100644 index 0000000..536e22f --- /dev/null +++ b/functions/log-e.fish @@ -0,0 +1,18 @@ +function log-e + if [ $DOTFISH_LOG_LEVEL -lt 10 ] + return + end + + set_color red + echo -n -- "$argv[1] " + set_color normal + + set_color --bold brred + echo -n -- "$argv[2]" + set_color normal + + set_color red + echo -n -- " $argv[3]" + echo + set_color normal +end diff --git a/functions/log-f.fish b/functions/log-f.fish new file mode 100644 index 0000000..623e052 --- /dev/null +++ b/functions/log-f.fish @@ -0,0 +1,21 @@ +function log-f + if [ $DOTFISH_LOG_LEVEL -lt 0 ] + return + end + + set_color --background red + set_color brwhite + echo -n -- "$argv[1] " + set_color normal + + set_color --background brred + set_color --bold brwhite + echo -n -- "$argv[2]" + set_color normal + + set_color --background red + set_color brwhite + echo -n -- " $argv[3]" + echo + set_color reset +end diff --git a/functions/log-i.fish b/functions/log-i.fish new file mode 100644 index 0000000..d9efdea --- /dev/null +++ b/functions/log-i.fish @@ -0,0 +1,18 @@ +function log-i + if [ $DOTFISH_LOG_LEVEL -lt 40 ] + return + end + + set_color cyan + echo -n -- "$argv[1] " + set_color normal + + set_color --bold brcyan + echo -n -- "$argv[2]" + set_color normal + + set_color cyan + echo -n -- " $argv[3]" + echo + set_color reset +end diff --git a/functions/log-s.fish b/functions/log-s.fish new file mode 100644 index 0000000..4bb47b4 --- /dev/null +++ b/functions/log-s.fish @@ -0,0 +1,18 @@ +function log-s + if [ $DOTFISH_LOG_LEVEL -lt 30 ] + return + end + + set_color green + echo -n -- "$argv[1] " + set_color normal + + set_color --bold brgreen + echo -n -- "$argv[2]" + set_color normal + + set_color green + echo -n -- " $argv[3]" + echo + set_color reset +end diff --git a/functions/log-t.fish b/functions/log-t.fish new file mode 100644 index 0000000..21ce73b --- /dev/null +++ b/functions/log-t.fish @@ -0,0 +1,18 @@ +function log-t + if [ $DOTFISH_LOG_LEVEL -lt 60 ] + return + end + + set_color purple + echo -n -- "$argv[1] " + set_color normal + + set_color --bold brpurple + echo -n -- "$argv[2]" + set_color normal + + set_color purple + echo -n -- " $argv[3]" + echo + set_color reset +end diff --git a/functions/log-w.fish b/functions/log-w.fish new file mode 100644 index 0000000..77b3a56 --- /dev/null +++ b/functions/log-w.fish @@ -0,0 +1,18 @@ +function log-w + if [ $DOTFISH_LOG_LEVEL -lt 20 ] + return + end + + set_color yellow + echo -n -- "$argv[1] " + set_color normal + + set_color --bold bryellow + echo -n -- "$argv[2]" + set_color normal + + set_color yellow + echo -n -- " $argv[3]" + echo + set_color reset +end diff --git a/functions/mv.fish b/functions/mv.fish index 058bca1..3dcc0ea 100644 --- a/functions/mv.fish +++ b/functions/mv.fish @@ -1,3 +1,6 @@ -function mv --wraps="mv" - command mv -i $argv; +which ls --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function mv --wraps="mv" + command mv --interactive --verbose $argv; + end end diff --git a/functions/redocker.fish b/functions/redocker.fish index 6b83aab..ce56c15 100644 --- a/functions/redocker.fish +++ b/functions/redocker.fish @@ -1,33 +1,21 @@ -function redocker - set project (docker compose config --format json | jq --raw-output .name) +which docker --skip-functions >/dev/null 2>/dev/null + if [ $status -eq 0 ] + function redocker + set project (docker compose config --format json | jq --raw-output .name) - echo_progress "Pulling images used by " - echo_highlight "$project" - echo_progress "..." - echo - docker compose pull + log-d "Pulling images used by " "$project" "..." + command docker compose pull - echo_progress "Building images using by " - echo_highlight "$project" - echo_progress "..." - echo - docker compose build + log-d "Building images using by " "$project" "..." + command docker compose build - echo_progress "Taking down " - echo_highlight "$project" - echo_progress "..." - echo - docker compose down + echo_progress "Taking down " "$project" "..." + command docker compose down - echo_progress "Bringing up " - echo_highlight "$project" - echo_progress "..." - echo - docker compose up -d - - echo_progress "Opening logs of " - echo_highlight "$project" - echo_progress "..." - echo - docker compose logs -f + echo_progress "Bringing up " "$project" "..." + command docker compose up -d + + echo_progress "Opening logs of " "$project" "..." + command docker compose logs -f + end end diff --git a/functions/rm.fish b/functions/rm.fish index 249b1d9..c442e27 100644 --- a/functions/rm.fish +++ b/functions/rm.fish @@ -1,3 +1,6 @@ -function rm --wraps="rm" - command rm -i $argv; +which rm --skip-functions >/dev/null 2>/dev/null +if [ $status -eq 0 ] + function rm --wraps="rm" + command rm --interactive="always" $argv + end end diff --git a/functions/sd+.fish b/functions/sd+.fish deleted file mode 100644 index 8b61964..0000000 --- a/functions/sd+.fish +++ /dev/null @@ -1,3 +0,0 @@ -function sd+ --wraps="systemctl enable" - systemctl enable --now $argv; -end diff --git a/functions/sd-.fish b/functions/sd-.fish deleted file mode 100644 index 919611b..0000000 --- a/functions/sd-.fish +++ /dev/null @@ -1,3 +0,0 @@ -function sd- --wraps="systemctl disable" - systemctl disable --now $argv; -end diff --git a/functions/sdj.fish b/functions/sdj.fish deleted file mode 100644 index 70ade7c..0000000 --- a/functions/sdj.fish +++ /dev/null @@ -1,3 +0,0 @@ -function sdj --wraps="journalctl" - journalctl --follow --unit=$argv[1] -end diff --git a/functions/sdr.fish b/functions/sdr.fish deleted file mode 100644 index d7e7819..0000000 --- a/functions/sdr.fish +++ /dev/null @@ -1,3 +0,0 @@ -function sdr --wraps="systemctl restart" - systemctl restart $argv; -end diff --git a/functions/sds.fish b/functions/sds.fish deleted file mode 100644 index 209cd29..0000000 --- a/functions/sds.fish +++ /dev/null @@ -1,3 +0,0 @@ -function sds --wraps="systemctl status" - systemctl status $argv; -end diff --git a/functions/ssh-start.fish b/functions/ssh-start.fish deleted file mode 100644 index 89823d6..0000000 --- a/functions/ssh-start.fish +++ /dev/null @@ -1,4 +0,0 @@ -function ssh-start - eval (ssh-agent -c) - ssh-add ~/.ssh/id_ed25519 -end diff --git a/functions/telegram-emoji.fish b/functions/telegram-emoji.fish deleted file mode 100644 index 090bc13..0000000 --- a/functions/telegram-emoji.fish +++ /dev/null @@ -1,7 +0,0 @@ -function telegram-emoji --wraps="magick" - echo_progress "Processing " - echo_highlight "$argv[1]" - echo_progress "..." - echo - magick -background none "$argv[1]" -resize "100x100^" -gravity center -extent 100x100 $argv[2..-1] "$argv[1].telegram-emoji.png" -end diff --git a/functions/telegram-sticker.fish b/functions/telegram-sticker.fish deleted file mode 100644 index 4f3cb6a..0000000 --- a/functions/telegram-sticker.fish +++ /dev/null @@ -1,7 +0,0 @@ -function telegram-sticker --wraps="magick" - echo_progress "Processing " - echo_highlight "$argv[1]" - echo_progress "..." - echo - magick -background none "$argv[1]" -resize 512x512 -gravity center $argv[2..-1] "$argv[1].telegram-sticker.png" -end diff --git a/functions/video-telegram.fish b/functions/video-telegram.fish new file mode 100644 index 0000000..018e26a --- /dev/null +++ b/functions/video-telegram.fish @@ -0,0 +1,3 @@ +function telegram-video + ffmpeg -i "$argv[1]" -filter:v 'scale=480:-1' -c:v 'h264_nvenc' -c:a 'copy' -crf '29' "$argv[1].crf29.mp4" +end