use catall function instead of a oneliner
This commit is contained in:
parent
04cf0101e0
commit
1d9470b5f1
3 changed files with 30 additions and 2 deletions
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
28
.config/fish/functions/catall.fish
Normal file
28
.config/fish/functions/catall.fish
Normal file
|
@ -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 <directory> exts ..."
|
||||
echo -e " $current_name [-h|--help] \t\t\t - Show this help message"
|
||||
echo -e " $current_name <directory> *.c \t\t - Cat all .C files"
|
||||
echo -e " $current_name <directory> *.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
|
Loading…
Reference in a new issue