Added Updates

This commit is contained in:
Hannes
2025-11-16 17:26:44 +01:00
parent 4c69b186f0
commit b16d05da76
21 changed files with 467 additions and 34 deletions

15
functions/compare_sha256.fish Executable file
View File

@@ -0,0 +1,15 @@
function compare_sha256
if test (count $argv) -ne 2
echo "Usage: compare_sha256 <file1> <file2>"
return 1
end
set hash1 (sha256sum $argv[1] | awk '{print $1}')
set hash2 (sha256sum $argv[2] | awk '{print $1}')
if test "$hash1" = "$hash2"
echo "Match"
else
echo "Different"
end
end

57
functions/extract.fish Executable file
View File

@@ -0,0 +1,57 @@
function extract
if test (count $argv) -lt 1
echo "Usage: extract <archive(s)> [output_directory]"
return 1
end
set output_dir "."
set archives $argv
# If there's more than one argument, check the last one for a directory
if test (count $argv) -gt 1
set maybe_dir $argv[-1]
if not test -f $maybe_dir
set output_dir $maybe_dir
mkdir -p $output_dir
set archives $argv[1..-2]
end
else
# If only one argument and it's a file, create directory with same name as archive (without extension)
set archive $argv[1]
if test -f "$archive"
set output_dir (string replace -r '\.(tar\.gz|tgz|tar\.bz2|tbz2|tar\.xz|txz|gz|bz2|xz|zst|zip|7z|rar)$' '' (basename "$archive"))
mkdir -p $output_dir
end
end
for archive in $archives
if not test -f "$archive"
echo "extract: '$archive' is not a valid file"
continue
end
set mime (file --mime-type -b "$archive")
switch $mime
case 'application/x-tar'
tar xvf "$archive" -C "$output_dir"
case 'application/gzip'
tar xvzf "$archive" -C "$output_dir" ^/dev/null; or gunzip -c "$archive" > "$output_dir/(basename (string replace -r '\.gz$' '' "$archive"))"
case 'application/x-bzip2'
tar xvjf "$archive" -C "$output_dir" ^/dev/null; or bunzip2 -c "$archive" > "$output_dir/(basename (string replace -r '\.bz2$' '' "$archive"))"
case 'application/x-xz'
tar xvJf "$archive" -C "$output_dir" ^/dev/null; or unxz -c "$archive" > "$output_dir/(basename (string replace -r '\.xz$' '' "$archive"))"
case 'application/zstd'
tar --zstd -xvf "$archive" -C "$output_dir" ^/dev/null; or unzstd -c "$archive" > "$output_dir/(basename (string replace -r '\.zst$' '' "$archive"))"
case 'application/zip'
unzip -j "$archive" -d "$output_dir"
case 'application/x-7z-compressed'
7z x "$archive" -o"$output_dir"
case 'application/x-rar' 'application/vnd.rar'
unrar x -o+ "$archive" "$output_dir"
case '*'
echo "extract: unknown file type for '$archive' ($mime)"
continue
end
end
end

15
functions/fish_prompt.fish_bak Executable file
View File

@@ -0,0 +1,15 @@
# Load pywal colors
set -g theme_0 (jq -r '.colors.color0' ~/.cache/wal/colors.json) # Color0 for general text
set -g theme_1 (jq -r '.colors.color1' ~/.cache/wal/colors.json) # Color1 for highlights (e.g., @ symbol)
set -g theme_2 (jq -r '.colors.color2' ~/.cache/wal/colors.json) # Color2 for hostname
set -g background_color (jq -r '.special.background' ~/.cache/wal/colors.json) # Background color
set -g foreground_color (jq -r '.special.foreground' ~/.cache/wal/colors.json) # Foreground color
# Customize your prompt
function fish_prompt
# Set background and foreground colors
echo -n (set_color $background_color) # Set background color
echo -n (set_color $foreground_color) # Set foreground color for text
echo -n (set_color $theme_0) 'user' (set_color $theme_1) '@' (set_color $theme_2) 'host' (set_color normal) '> '
end

16
functions/pack.fish Executable file
View File

@@ -0,0 +1,16 @@
function pack
if test (count $argv) -lt 2
echo "Usage: pack <archive-name> <file-or-dir> [more files...]"
return 1
end
set archive $argv[1]
set targets $argv[2..-1]
# Ensure .tar.xz extension
if not string match -r '\.tar\.xz$' -- $archive
set archive "$archive.tar.xz"
end
tar -cJvf $archive $targets
end