guidofe / bash-cat-with-cat Goto Github PK
View Code? Open in Web Editor NEWThe classic cat command but with a cat
The classic cat command but with a cat
Cats usually have tails.
I think the bash cat should also have one.
How exactly do I get this to replace my default cat
command?
so our cat is cool ,
but it's add cat shape to txt file in following case
cat >> file.txt
I'm trying to cat a file with spaces in its path, but here's what I get:
$ kat Space\ Test/test.txt
∧_∧
( ・ω・)
―――――――――――――――――――――――――――――∪――――∪――――――――――――――――――――――――――――――
cat: Space: No such file or directory
cat: Test/test.txt: No such file or directory
_________________________________________________________________
| |
| |
U U
I tried kat 'Space Test/test.txt'
, but it fails as well.
This is probably an unnecessary question considering the nature of the repository (a funny bash cat), but is it okay to copy/redistribute the script? In a personal dotfiles repo, for example.
I imagine you wouldn't mind, but if that's the case, would you consider adding a license to make that explicit?
If you don't want to attach your name to the project so strongly, you could use something like the unlicense.
Thanks for writing this, anyway. The cat is pretty funny.
When I tried to use the cat.sh script provided with a simple html file, I got this:
However, this was fixed by adding a blank padding/line between the cat
output. Modified the script to become:
#!/bin/bash
if [ ! -t 1 ] ; then
cat "$@"
exit 0
fi
ncol=`tput cols`
# If you modify the cat, be sure to mantain the same length in every line (newline excluded).
# Leave an empty array index where you want the cat output, and specify it in OUTPUT_INDEX.
# Modify UPPER and LOWER_LINE INDEX and CHAR if you want to modify the appearance and position
# of the two delimiters, or set their index at -1 if you don't want them.
t[0]=' ∧_∧ '
t[1]=' ( ・ω・) '
t[2]='―∪――――∪―'
t[3]=' '
t[5]=' '
t[6]='________'
t[7]=' | | '
t[8]=' | | '
t[9]=' U U '
#################################
# #
# Modify these constants if you #
# modify the drawing #
# #
#################################
# Drawing width without newlines
DRAWING_WIDTH=8
OUTPUT_INDEX=4
UPPER_LINE_CHAR="―"
UPPER_LINE_INDEX=2
LOWER_LINE_INDEX=6
LOWER_LINE_CHAR="_"
# Percentage that indicates the position of the drawing
# in the terminal. 0 = align to the left, 100 = align to
# the right
DRAWING_POSITION=25
#################################
arrayLen=${#t[@]}
halfDrawingLen=$(($DRAWING_WIDTH / 2))
leadingSpaces=$(($ncol * $DRAWING_POSITION / 100 - $halfDrawingLen))
if [[ $leadingSpaces -lt 0 ]]; then
leadingSpaces=0
fi
trailingSpaces=$(($ncol - $leadingSpaces - $DRAWING_WIDTH))
if [[ $leadingSpaces -gt $(($ncol - $DRAWING_WIDTH)) ]]; then
leadingSpaces=$(($ncol - $DRAWING_WIDTH))
trailingSpaces=0
fi
echo ""
for i in $(seq 0 $arrayLen); do
if [[ $i = $OUTPUT_INDEX ]]; then
cat "$@"
else
car=""
if [[ $i = $UPPER_LINE_INDEX ]]; then
car=$UPPER_LINE_CHAR
elif [[ $i = $LOWER_LINE_INDEX ]]; then
car=$LOWER_LINE_CHAR
else
car=" "
fi
for s in $(seq 1 $leadingSpaces); do
printf "$car"
done
printf "${t[$i]}"
if [[ $i -eq $LOWER_LINE_INDEX || $i -eq $UPPER_LINE_INDEX ]]; then
for s in $(seq 1 $trailingSpaces); do
printf "$car"
done
printf "\n"
else
printf "\n"
fi
fi
done
echo ""
This helped to resolve my issue and now it correctly prints out the html file:
Just wanted to share this here, in case anyone else was facing this problem.
Cheers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.