1
Fork 0
mirror of https://github.com/Steffo99/config-fish.git synced 2024-10-16 06:17:34 +00:00
This commit is contained in:
Steffo 2024-08-21 11:45:18 +02:00
parent 64055908d3
commit 62635388c2
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
35 changed files with 260 additions and 114 deletions

17
completions/pipx.fish Normal file
View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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

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

View file

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

View file

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

View file

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

View file

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

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 normal
set_color --bold brblue
echo -n -- "$argv[2]"
set_color normal
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" "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

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 normal
set_color --bold brred
echo -n -- "$argv[2]"
set_color normal
set_color red
echo -n -- " $argv[3]"
echo
set_color normal
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 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

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 normal
set_color --bold brcyan
echo -n -- "$argv[2]"
set_color normal
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 normal
set_color --bold brgreen
echo -n -- "$argv[2]"
set_color normal
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 normal
set_color --bold brpurple
echo -n -- "$argv[2]"
set_color normal
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 normal
set_color --bold bryellow
echo -n -- "$argv[2]"
set_color normal
set_color yellow
echo -n -- " $argv[3]"
echo
set_color reset
end

View file

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

View file

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

View file

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

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