function cleanpycs find . -name '.git' -o -name __pycache__ -delete find . -name '.git' -o -name '*.py[co]' -delete end function envsource if not set -q argv[1] set argv[1] ".env" end echo "Using $argv[1] as input file" for line in (grep -v '^\s*\(#\|$\)' $argv[1] | grep -E '^[A-Za-z_]+=[^#\n]+') set item (string split -m 1 '=' $line) set -gx $item[1] $item[2] echo "Exported key $item[1]" end end function envunset if not set -q argv[1] set argv[1] ".env" end echo "Using $argv[1] as input file" for line in (grep -v '^\s*\(#\|$\)' $argv[1] | grep -E '^[A-Za-z_]+=[^#\n]+') set item (string split -m 1 '=' $line) set -e $item[1] echo "key $item[1] unset" end end function gen-secret if not set -q argv[1] set argv[1] 64 end openssl rand -hex $argv[1] end function ffmerge set input_videos for arg in $argv if test (string sub -l 4 $arg) = ".mp4" set input_videos $input_videos -i $arg else set output $arg end end ffmpeg $input_videos -filter_complex (printf "[%s] " $input_videos | sed 's/ -i / concat=n=%d:v=1:a=1 [v] [a]/') -map "[v]" -map "[a]" $output end function fish_right_prompt set -l k8s_color (set_color blue) set -l k8s_context (kubectl config current-context) echo -e -n -s $k8s_color "($k8s_context)" end function gr if not set -q argv[1] set argv[1] 1 end git reset "HEAD~$argv[1]" end function gur if not set -q argv[1] set argv[1] 1 end git reset "HEAD@{$argv[1]}" end function nix_upgrade sudo nix flake update --flake /home/catalin/.dotfiles/nix/ sudo nixos-rebuild switch --flake /home/catalin/.dotfiles/nix/ --upgrade end function delete_line if test (count $argv) -lt 2 echo "Usage: delete_line [--backup]" return 1 end set file $argv[1] set line_num $argv[2] set make_backup false if contains -- --backup $argv set make_backup true end if not test -f $file echo "Error: File '$file' does not exist" return 1 end if not string match -qr '^\d+$' $line_num echo "Error: Line number must be a positive integer" return 1 end set total_lines (wc -l < $file) if test $line_num -gt $total_lines echo "Error: Line $line_num does not exist (file has only $total_lines lines)" return 1 end if test $make_backup = true cp $file $file.bak echo "Backup created: $file.bak" end sed -i "$line_num"d $file echo "Deleted line $line_num from $file" end