diff --git a/.config/fish/conf.d/abbr_arch.fish b/.config/fish/conf.d/abbr_arch.fish index 4d4c0a1..0e30c5e 100644 --- a/.config/fish/conf.d/abbr_arch.fish +++ b/.config/fish/conf.d/abbr_arch.fish @@ -5,7 +5,7 @@ abbr vs "codium ." abbr xclip "xclip -selection clipboard" abbr spotx "bash -c 'bash <(curl -sSL https://spotx-official.github.io/run.sh) -ce'" abbr rm "trash -f" -abbr catall "find . \( -name '*.ext1' -o -name '*.ext2' \) -exec echo "File: {}" \; -exec cat {} \; | xclip -selection clipboard" +abbr catall "catall .*ext1 .*ext2 | xclip -selection clipboard" abbr ll "eza --git --icons -gl" abbr la "eza --git --icons -gla" abbr pdf "firefox *.pdf & disown" diff --git a/.config/fish/conf.d/abbr_wsl.fish b/.config/fish/conf.d/abbr_wsl.fish index 5a892d0..a91446d 100644 --- a/.config/fish/conf.d/abbr_wsl.fish +++ b/.config/fish/conf.d/abbr_wsl.fish @@ -3,6 +3,6 @@ abbr unison "unison ~/src ~/u_dest" abbr vs "code ." abbr wgcc x86_64-w64-mingw32-gcc abbr rm "rm -rf" -abbr catall "find . \( -name '*.ext1' -o -name '*.ext2' \) -exec echo "File `{}`:" \; -exec cat {} \; | clip.exe" +abbr catall "catall .*ext1 .*ext2 | clip.exe" abbr ll "eza --git -gl" abbr la "eza --git -gla" diff --git a/.config/fish/functions/catall.fish b/.config/fish/functions/catall.fish new file mode 100644 index 0000000..3c6d940 --- /dev/null +++ b/.config/fish/functions/catall.fish @@ -0,0 +1,28 @@ +function catall2 --description "Print recursively multiple files." + # Get function name + set current_name $(status current-function) + + # Check if no arguments were provided, or if the first argument is '--help' + if test -z $argv[2] || test "$argv[1]" = --help || test "$argv[1]" = -h + echo -e "Usage: $current_name exts ..." + echo -e " $current_name [-h|--help] \t\t\t - Show this help message" + echo -e " $current_name *.c \t\t - Cat all .C files" + echo -e " $current_name *.c *.h ... \t - Cat .C and .H files, etc." + return 0 + end + + # Define directory + set directory $argv[1] + + # Define extensions + set exts -name "$argv[2]" + for ext in $argv[3..-1] + set -a exts -o -name "$ext" + end + + # Extra args for better printing + set args -exec echo -e "File: {}" \; -exec cat {} \; -exec echo "" \; + + # Print files + find $directory \( $exts \) $args +end