1
Fork 0
mirror of https://github.com/Steffo99/config-fish.git synced 2024-10-16 14:27:34 +00:00

Compare commits

..

9 commits

48 changed files with 2250 additions and 145 deletions

1825
completions/uv.fish Normal file

File diff suppressed because it is too large Load diff

View file

@ -1 +0,0 @@
fish_add_path ~"/.local/bin"

View file

@ -1,3 +0,0 @@
fish_add_path ~"/.local/share/gem/ruby/3.0.0/bin"
fish_add_path ~"/.gem/ruby/3.0.0/bin"

View file

@ -16,3 +16,5 @@ 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" "50"

View file

View file

@ -1,3 +1,7 @@
which btm --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function btm --wraps="btm"
log-t "Running" "btm" "with the GPU memory display enabled..."
command btm --enable_gpu_memory $argv;
end
end

View file

@ -1,3 +1,7 @@
which clear --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function cls --wraps="clear"
clear $argv;
log-t "" "Clearing" "the screen..."
command clear $argv
end
end

View file

@ -1,4 +1,5 @@
function confirm
log-t "Asking for a" "confirmation" "..."
set -g ANSWER (read -n 1 -P "Confirm? (y/N) ")
if test -z $ANSWER

View file

@ -1,3 +1,7 @@
which cp --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function cp --wraps="cp"
command cp -i $argv;
log-t "Performing a" "safe copy" "..."
command cp --interactive --verbose $argv;
end
end

View file

@ -1,43 +1,42 @@
function dotfish
log-i "Running" "dotfish" "update..."
if test (count $argv) -eq 0
set -g argv (whoami)
log-d "No users specified, running on" "$argv" ""
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-t "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-t "Deleting old config at" "$FISHCONFIG" "..."
command rm -rf "$FISHCONFIG"
else
echo_progress "Deletion was refused, skipping..." \n
log-t "Deletion rejected, not touching" "$FISHCONFIG" "."
continue
end
end
log-t "Fixing permissions at" "$FISHCONFIG" "..."
command chown -R "$TARGET:" "$FISHCONFIG"
if test -d "$FISHCONFIG"
echo_progress "Existing config detected, pulling from Git..." \n
git -C "$FISHCONFIG" pull
log-t "Existing config detected at" "$FISHCONFIG" "pulling from Git..."
command sudo -u "$TARGET" -- git -C "$FISHCONFIG" pull
else
echo_progress "No config detected, cloning from Git..." \n
git clone "https://github.com/Steffo99/.config-fish" "$FISHCONFIG"
log-t "No config detected, cloning from Git into" "$FISHCONFIG" "..."
command sudo -u "$TARGET" -- git clone "https://github.com/Steffo99/.config-fish" "$FISHCONFIG"
end
echo_progress "Fixing permissions..." \n
chown -R "$TARGET:" "$FISHCONFIG"
echo_progress "Changing login shell..." \n
chsh -s "/usr/bin/fish" "$TARGET"
echo_progress "Update complete!" \n
log-t "Changing login shell to" "/usr/bin/fish" "..."
command chsh -s "/usr/bin/fish" "$TARGET"
end
log-s "Dotfish updated successfully for" "$argv" "!"
end

View file

@ -1,3 +1,7 @@
which sudo --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function dudo --wraps="sudo"
sudo $argv;
log-t "just do as" "superuser" ", bro"
command sudo $argv
end
end

View file

@ -1,5 +0,0 @@
function echo_error --wraps="echo"
set_color brred --bold
echo -n $argv
set_color normal
end

View file

@ -1,5 +0,0 @@
function echo_highlight --wraps="echo"
set_color yellow
echo -n $argv
set_color normal
end

View file

@ -1,5 +0,0 @@
function echo_progress --wraps="echo"
set_color yellow --dim
echo -n $argv
set_color normal
end

View file

@ -1,7 +1,7 @@
function fish_prompt
# Save variables before they are gone
set "STATUS" $status
set "UID" (id -u)
set "DOTFISH_STATUS" $status
set "DOTFISH_UID" (id -u)
# User name
@ -65,16 +65,16 @@ function fish_prompt
# Exit status
if test $STATUS -ne 0
if test $DOTFISH_STATUS -ne 0
set_color brred
echo -n "[$STATUS]"
echo -n "[$DOTFISH_STATUS]"
end
set_color normal
# Dollar
set_color --bold white
if test "$UID" -eq 0
if test "$DOTFISH_UID" -eq 0
echo -n "# "
else
echo -n "\$ "

View file

@ -0,0 +1,74 @@
function fish_right_prompt
if [ -f "compose.yml" ]
set --local docker_pod_name (docker compose config --format="json" | jq --raw-output '.name')
set --local docker_pod_states_output (docker compose ps --format="json" --all | jq --slurp --raw-output '.[].State')
set --local docker_pod_created_count (echo "$docker_pod_states_output" | grep --only-matching 'created' - | wc --lines)
set --local docker_pod_running_count (echo "$docker_pod_states_output" | grep --only-matching 'running' - | wc --lines)
set --local docker_pod_restarting_count (echo "$docker_pod_states_output" | grep --only-matching 'restarting' - | wc --lines)
set --local docker_pod_exited_count (echo "$docker_pod_states_output" | grep --only-matching 'exited' - | wc --lines)
set --local docker_pod_paused_count (echo "$docker_pod_states_output" | grep --only-matching 'paused' - | wc --lines)
set --local docker_pod_dead_count (echo "$docker_pod_states_output" | grep --only-matching 'dead' - | wc --lines)
set_color white
echo -n -- "{"
set_color reset
if [ "$docker_pod_dead_count" -gt 0 ]
set_color --bold brblack
else if [ "$docker_pod_exited_count" -gt 0 ]
set_color --bold brred
else if [ "$docker_pod_restarting_count" -gt 0 ]
set_color --bold brmagenta
else if [ "$docker_pod_paused_count" -gt 0 ]
set_color --bold bryellow
else if [ "$docker_pod_running_count" -gt 0 ]
set_color --bold brgreen
else if [ "$docker_pod_created_count" -gt 0 ]
set_color --bold brcyan
else
set_color --bold brwhite
end
echo -n -- "$docker_pod_name"
set_color reset
if [ "$docker_pod_dead_count" -gt 0 ]
set_color brblack
echo -n -- " $docker_pod_dead_count"
set_color reset
end
if [ "$docker_pod_exited_count" -gt 0 ]
set_color brred
echo -n -- " $docker_pod_exited_count"
set_color reset
end
if [ "$docker_pod_restarting_count" -gt 0 ]
set_color brmagenta
echo -n -- " $docker_pod_restarting_count"
set_color reset
end
if [ "$docker_pod_paused_count" -gt 0 ]
set_color bryellow
echo -n -- " $docker_pod_paused_count"
set_color reset
end
if [ "$docker_pod_running_count" -gt 0 ]
set_color brgreen
echo -n -- " $docker_pod_running_count"
set_color reset
end
if [ "$docker_pod_created_count" -gt 0 ]
set_color brcyan
echo -n -- " $docker_pod_created_count"
set_color reset
end
set_color white
echo -n -- "}"
set_color reset
end
end

View file

@ -0,0 +1,10 @@
which magick --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function gen-emoji-akkoma --wraps=magick
log-t "Creating" "Akkoma" "directory..."
command mkdir --parents "Akkoma"
log-d "Processing" "$argv[1]" "for Akkoma use..."
command magick -background none "$argv[1]" -resize "106x106^" -gravity center -extent 106x106 $argv[2..-1] "Akkoma/$argv[1]"
log-t "Done! Emoji added to the" "Akkoma" "directory!"
end
end

View file

@ -0,0 +1,10 @@
which magick --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function gen-emoji-discord --wraps=magick
log-t "Creating" "Discord" "directory..."
command mkdir --parents "Discord"
log-d "Processing" "$argv[1]" "for Discord use..."
command magick -background none "$argv[1]" -resize "128x128^" -gravity center -extent 128x128 $argv[2..-1] "Discord/$argv[1]"
log-t "Done! Emoji added to the" "Discord" "directory!"
end
end

View file

@ -0,0 +1,10 @@
which magick --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function gen-emoji-telegram --wraps=magick
log-t "Creating" "Telegram" "directory..."
command mkdir --parents "Telegram"
log-d "Processing" "$argv[1]" "for Telegram use..."
command magick -background none "$argv[1]" -resize "100x100^" -gravity center -extent 100x100 $argv[2..-1] "Telegram/$argv[1]"
log-t "Done! Emoji added to the" "Telegram" "directory!"
end
end

View file

@ -0,0 +1,10 @@
which magick --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function gen-emojis-akkoma
for arg in $argv
log-i "Processing" "$arg" "..."
gen-emoji-akkoma "$arg"
end
log-s "All emojis generated successfully!"
end
end

View file

@ -0,0 +1,12 @@
which magick --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function gen-emojis-all
for arg in $argv
log-i "Processing" "$arg" "..."
gen-emoji-akkoma "$arg"
gen-emoji-discord "$arg"
gen-emoji-telegram "$arg"
end
log-s "All emojis generated successfully!"
end
end

View file

@ -0,0 +1,10 @@
which magick --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function gen-emojis-discord
for arg in $argv
log-i "Processing" "$arg" "..."
gen-emoji-discord "$arg"
end
log-s "All emojis generated successfully!"
end
end

View file

@ -0,0 +1,10 @@
which magick --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function gen-emojis-telegram
for arg in $argv
log-i "Processing" "$arg" "..."
gen-emoji-telegram "$arg"
end
log-s "All emojis generated successfully!"
end
end

View file

@ -1,3 +0,0 @@
function idea --wraps="idea"
command idea -e -w $argv;
end

View file

@ -1,3 +1,7 @@
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
log-t "" "Listing" "all files in the directory..."
command ls --all --author --color --kibibytes --human-readable --group-directories-first -l $argv;
end
end

18
functions/log-d.fish Normal file
View file

@ -0,0 +1,18 @@
function log-d
if [ $DOTFISH_LOG_LEVEL -lt 50 ]
return
end
set_color blue
echo -n -- "$argv[1] "
set_color reset
set_color --bold brblue
echo -n -- "$argv[2]"
set_color reset
set_color blue
echo -n -- " $argv[3]"
echo
set_color reset
end

9
functions/log-demo.fish Normal file
View file

@ -0,0 +1,9 @@
function log-demo
log-t "This is a" "[t]race (60)" "log."
log-d "This is a" "[d]ebug (50)" "log."
log-i "This is a" "[i]nformation (40)" "log."
log-s "This is a" "[s]uccess (30)" "log."
log-w "This is a" "[w]arning (20)" "log."
log-e "This is a" "[e]rror (10)" "log."
log-f "This is a" "[f]atal (0)" "log."
end

18
functions/log-e.fish Normal file
View file

@ -0,0 +1,18 @@
function log-e
if [ $DOTFISH_LOG_LEVEL -lt 10 ]
return
end
set_color red
echo -n -- "$argv[1] "
set_color reset
set_color --bold brred
echo -n -- "$argv[2]"
set_color reset
set_color red
echo -n -- " $argv[3]"
echo
set_color reset
end

21
functions/log-f.fish Normal file
View file

@ -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 reset
set_color --background brred
set_color --bold brwhite
echo -n -- "$argv[2]"
set_color reset
set_color --background red
set_color brwhite
echo -n -- " $argv[3]"
echo
set_color reset
end

18
functions/log-i.fish Normal file
View file

@ -0,0 +1,18 @@
function log-i
if [ $DOTFISH_LOG_LEVEL -lt 40 ]
return
end
set_color cyan
echo -n -- "$argv[1] "
set_color reset
set_color --bold brcyan
echo -n -- "$argv[2]"
set_color reset
set_color cyan
echo -n -- " $argv[3]"
echo
set_color reset
end

18
functions/log-s.fish Normal file
View file

@ -0,0 +1,18 @@
function log-s
if [ $DOTFISH_LOG_LEVEL -lt 30 ]
return
end
set_color green
echo -n -- "$argv[1] "
set_color reset
set_color --bold brgreen
echo -n -- "$argv[2]"
set_color reset
set_color green
echo -n -- " $argv[3]"
echo
set_color reset
end

18
functions/log-t.fish Normal file
View file

@ -0,0 +1,18 @@
function log-t
if [ $DOTFISH_LOG_LEVEL -lt 60 ]
return
end
set_color purple
echo -n -- "$argv[1] "
set_color reset
set_color --bold brpurple
echo -n -- "$argv[2]"
set_color reset
set_color purple
echo -n -- " $argv[3]"
echo
set_color reset
end

18
functions/log-w.fish Normal file
View file

@ -0,0 +1,18 @@
function log-w
if [ $DOTFISH_LOG_LEVEL -lt 20 ]
return
end
set_color yellow
echo -n -- "$argv[1] "
set_color reset
set_color --bold bryellow
echo -n -- "$argv[2]"
set_color reset
set_color yellow
echo -n -- " $argv[3]"
echo
set_color reset
end

View file

@ -1,3 +1,7 @@
which ls --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function mv --wraps="mv"
command mv -i $argv;
log-t "Performing a" "safe move" "..."
command mv --interactive --verbose $argv;
end
end

View file

@ -1,33 +1,24 @@
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)
log-i "Re-instantiating" "$project" "..."
echo_progress "Pulling images used by "
echo_highlight "$project"
echo_progress "..."
echo
docker compose pull
log-t "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-t "Building images using by " "$project" "..."
command docker compose build
echo_progress "Taking down "
echo_highlight "$project"
echo_progress "..."
echo
docker compose down
log-t "Taking down " "$project" "..."
command docker compose down
echo_progress "Bringing up "
echo_highlight "$project"
echo_progress "..."
echo
docker compose up -d
log-t "Bringing up " "$project" "..."
command docker compose up -d
echo_progress "Opening logs of "
echo_highlight "$project"
echo_progress "..."
echo
docker compose logs -f
log-s "Re-instantiated" "$project" "!"
log-t "Opening logs of " "$project" "..."
command docker compose logs -f
end
end

View file

@ -1,3 +1,7 @@
which rm --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function rm --wraps="rm"
command rm -i $argv;
log-t "Performing a" "safe delete" "..."
command rm --interactive="always" $argv
end
end

View file

@ -1,3 +0,0 @@
function sd+ --wraps="systemctl enable"
systemctl enable --now $argv;
end

View file

@ -1,3 +0,0 @@
function sd- --wraps="systemctl disable"
systemctl disable --now $argv;
end

View file

@ -1,3 +0,0 @@
function sdj --wraps="journalctl"
journalctl --follow --unit=$argv[1]
end

View file

@ -1,3 +0,0 @@
function sdr --wraps="systemctl restart"
systemctl restart $argv;
end

View file

@ -1,3 +0,0 @@
function sds --wraps="systemctl status"
systemctl status $argv;
end

View file

@ -1,4 +1,9 @@
which ssh-agent --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function ssh-start
log-t "Starting" "ssh-agent" "..."
eval (ssh-agent -c)
log-t "Adding" "private key" "to the agent..."
ssh-add ~/.ssh/id_ed25519
end
end

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,7 @@
which docker --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
function video-telegram
log-t "Converting" "$argv[1]" "to chat optimized format..."
ffmpeg -i "$argv[1]" -filter:v 'scale=480:-1' -c:v 'h264_nvenc' -c:a 'copy' -crf '29' "$argv[1].crf29.mp4"
end
end

4
functions/work-on.fish Normal file
View file

@ -0,0 +1,4 @@
function work-on --wraps="cd /mnt/work/steffo"
set --global DOTFISH_WORKSPACE $argv[1]
cd "/mnt/work/steffo/$DOTFISH_WORKSPACE" $argv[2..-1]
end

5
path/cargo.fish Normal file
View file

@ -0,0 +1,5 @@
which cargo --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
log-t "Adding" "cargo" "binaries to the PATH..."
fish_add_path ~"/.cargo/bin"
end

5
path/uv.fish Normal file
View file

@ -0,0 +1,5 @@
which uv --skip-functions >/dev/null 2>/dev/null
if [ $status -eq 0 ]
log-t "Adding" "uv" "binaries to the PATH..."
fish_add_path ~"/.local/bin"
end