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

Compare commits

..

No commits in common. "e9395c37872ca9e2d91e7733e124171c516df45c" and "64055908d3cb7904603a36e7859b122724bec417" have entirely different histories.

48 changed files with 145 additions and 2250 deletions

File diff suppressed because it is too large Load diff

1
conf.d/pipx.fish Normal file
View file

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

3
conf.d/rubygems.fish Normal file
View file

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

View file

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

0
fish_plugins Normal file
View file

View file

@ -1,7 +1,3 @@
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
function btm --wraps="btm"
command btm --enable_gpu_memory $argv;
end

View file

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

View file

@ -1,14 +1,13 @@
function confirm
log-t "Asking for a" "confirmation" "..."
set -g ANSWER (read -n 1 -P "Confirm? (y/N) ")
set -g ANSWER (read -n 1 -P "Confirm? (y/N) ")
if test -z $ANSWER
return 1
else if test $ANSWER = "y"
return 0
else if test $ANSWER = "Y"
return 0
else
return 1
end
if test -z $ANSWER
return 1
else if test $ANSWER = "y"
return 0
else if test $ANSWER = "Y"
return 0
else
return 1
end
end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,5 @@
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 "DOTFISH_STATUS" $status
set "DOTFISH_UID" (id -u)
set "STATUS" $status
set "UID" (id -u)
# User name
@ -65,16 +65,16 @@ function fish_prompt
# Exit status
if test $DOTFISH_STATUS -ne 0
if test $STATUS -ne 0
set_color brred
echo -n "[$DOTFISH_STATUS]"
echo -n "[$STATUS]"
end
set_color normal
# Dollar
set_color --bold white
if test "$DOTFISH_UID" -eq 0
if test "$UID" -eq 0
echo -n "# "
else
echo -n "\$ "

View file

@ -1,74 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,12 +0,0 @@
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

@ -1,10 +0,0 @@
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

@ -1,10 +0,0 @@
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

3
functions/idea.fish Normal file
View file

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

View file

@ -1,7 +1,3 @@
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
function ll --wraps="ls"
ls --all --author --color --kibibytes --human-readable -l $argv;
end

View file

@ -1,18 +0,0 @@
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

View file

@ -1,9 +0,0 @@
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

View file

@ -1,18 +0,0 @@
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

View file

@ -1,21 +0,0 @@
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

View file

@ -1,18 +0,0 @@
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

View file

@ -1,18 +0,0 @@
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

View file

@ -1,18 +0,0 @@
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

View file

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

View file

@ -1,24 +1,33 @@
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" "..."
function redocker
set project (docker compose config --format json | jq --raw-output .name)
log-t "Pulling images used by " "$project" "..."
command docker compose pull
echo_progress "Pulling images used by "
echo_highlight "$project"
echo_progress "..."
echo
docker compose pull
log-t "Building images using by " "$project" "..."
command docker compose build
echo_progress "Building images using by "
echo_highlight "$project"
echo_progress "..."
echo
docker compose build
log-t "Taking down " "$project" "..."
command docker compose down
echo_progress "Taking down "
echo_highlight "$project"
echo_progress "..."
echo
docker compose down
log-t "Bringing up " "$project" "..."
command docker compose up -d
log-s "Re-instantiated" "$project" "!"
log-t "Opening logs of " "$project" "..."
command docker compose logs -f
end
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
end

View file

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

3
functions/sd+.fish Normal file
View file

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

3
functions/sd-.fish Normal file
View file

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

3
functions/sdj.fish Normal file
View file

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

3
functions/sdr.fish Normal file
View file

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

3
functions/sds.fish Normal file
View file

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

View file

@ -1,9 +1,4 @@
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
function ssh-start
eval (ssh-agent -c)
ssh-add ~/.ssh/id_ed25519
end

View file

@ -0,0 +1,7 @@
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

@ -0,0 +1,7 @@
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

@ -1,7 +0,0 @@
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

View file

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

View file

@ -1,5 +0,0 @@
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

View file

@ -1,5 +0,0 @@
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