I know that I can initialize artii on the cmd with:
artii "word"
And WORD appears, but I cant find how to do this directly from a .rb file.
Artii::Base#asciify returns a formatted string:
require 'artii'
a = Artii::Base.new
a.asciify('word')
#=> " _ \n | |\n __ _____ _ __ __| |\n \\ \\ /\\ / / _ \\| '__/ _` |\n \\ V V / (_) | | | (_| |\n \\_/\\_/ \\___/|_| \\__,_|\n \n "
You have to print it in order to see the formatting:
puts a.asciify('word')
Output:
_
| |
__ _____ _ __ __| |
\ \ /\ / / _ \| '__/ _` |
\ V V / (_) | | | (_| |
\_/\_/ \___/|_| \__,_|
Related
I would like to print a MOTD using styled text when an user connects to the server (ubuntu 18.04) using SSH.
The only way I found is to print the file by myself because Ubuntu originally only cats the motd file.
So now, I have a colord motd file but I don't found any way to print out the contents with the style.
I found this command on stackoverflow:
cat /home/user/conf/bash/motd | sed 's/$/\\n/' | sed 's/ /\\a /g'
But this is not working propertly with large ASCII text.
here is the current test motd file
____ ____ ________ _____ ______ ___ ____ ____ ________
|_ _| |_ _||_ __ ||_ _| .' ___ | .' `.|_ \ / _||_ __ |
\ \ /\ / / | |_ \_| | | / .' \_|/ .-. \ | \/ | | |_ \_|
\ \/ \/ / | _| _ | | _ | | | | | | | |\ /| | | _| _
\ /\ / _| |__/ | _| |__/ |\ `.___.'\\ `-' /_| |_\/_| |_ _| |__/ |
\/ \/ |________||________| `.____ .' `.___.'|_____||_____||________|
Welcome to my Server !
Aliases:
\e[4ml\e[0m => ls -lA
\e[1;93mll\e[0m => ls -l
Have you any solution to do it please ?
Hi i'm using my color table when i need colors in scripts. Here it is.
#!/bin/bash
#--------------------------------------------------------------------+
#Color picker, usage: printf ${BLD}${CUR}${RED}${BBLU}"Hello!)"${DEF}|
#-------------------------+--------------------------------+---------+
# Text color | Background color | |
#-----------+-------------+--------------+-----------------+ |
# Base color|Lighter shade| Base color | Lighter shade | |
#-----------+-------------+--------------+-----------------+ |
BLK='\e[30m'; blk='\e[90m'; BBLK='\e[40m'; bblk='\e[100m' #| Black |
RED='\e[31m'; red='\e[91m'; BRED='\e[41m'; bred='\e[101m' #| Red |
GRN='\e[32m'; grn='\e[92m'; BGRN='\e[42m'; bgrn='\e[102m' #| Green |
YLW='\e[33m'; ylw='\e[93m'; BYLW='\e[43m'; bylw='\e[103m' #| Yellow |
BLU='\e[34m'; blu='\e[94m'; BBLU='\e[44m'; bblu='\e[104m' #| Blue |
MGN='\e[35m'; mgn='\e[95m'; BMGN='\e[45m'; bmgn='\e[105m' #| Magenta |
CYN='\e[36m'; cyn='\e[96m'; BCYN='\e[46m'; bcyn='\e[106m' #| Cyan |
WHT='\e[37m'; wht='\e[97m'; BWHT='\e[47m'; bwht='\e[107m' #| White |
#----------------------------------------------------------+---------+
# Effects |
#--------------------------------------------------------------------+
DEF='\e[0m' #Default color and effects |
BLD='\e[1m' #Bold\brighter |
DIM='\e[2m' #Dim\darker |
CUR='\e[3m' #Italic font |
UND='\e[4m' #Underline |
INV='\e[7m' #Inverted |
COF='\e[?25l' #Cursor Off |
CON='\e[?25h' #Cursor On |
#--------------------------------------------------------------------+
# Text positioning, usage: XY 10 10 "Hello World!" |
XY () { printf "\e[${2};${1}H${3}"; } # |
#--------------------------------------------------------------------+
# Print line, usage: line - 10 | line -= 20 | line "Hello World!" 20 |
line () { printf -v LINE "%$2s"; printf -- "${LINE// /$1}"; } # |
# Create sequence like {0..X} |
cnt () { printf -v _N %$1s; _N=(${_N// / 1}); printf "${!_N[*]}"; } #|
#--------------------------------------------------------------------+
welcome=(''
$RED" ____ ____ ________ _____ ______ ___ ____ ____ ________ \n"$DEF
$RED"|_ _| |_ _||_ __ ||_ _| .' ___ | .' \`.|_ \ / _||_ __ | \n"$DEF
$GRN" \ \ /\ / / | |_ \_| | | / .' \_|/ .-. \ | \/ | | |_ \_| \n"$DEF
$GRN" \ \/ \/ / | _| _ | | _ | | | | | | | |\ /| | | _| _ \n"$DEF
$BLU" \ /\ / _| |__/ | _| |__/ |\ \`.___.'\\\\\ \`-' /_| |_\/_| |_ _| |__/ |\n"$DEF
$BLU" \/ \/ |________||________| \`.____ .' \`.___.'|_____||_____||________| \n"$DEF
)
printf "${welcome[*]}"
I would use variable in my file but It's seems that parsing variable implies parsing other things so it's not compatible with the banner that is ASCII only.
So I exported the banner to another file and now, I am able to print color and the banner.
Here is the SH sample
RED="\e[31m"
BANNER=$(<banner.txt)
printf "$(eval "echo \"$(<myfile.txt)\"")"
banner.txt
____ ____ ________ _____ ______ ___ ____ ____ ________
|_ _| |_ _||_ __ ||_ _| .' ___ | .' `.|_ \ / _||_ __ |
\ \ /\ / / | |_ \_| | | / .' \_|/ .-. \ | \/ | | |_ \_|
\ \/ \/ / | _| _ | | _ | | | | | | | |\ /| | | _| _
\ /\ / _| |__/ | _| |__/ |\ `.___.'\\ `-' /_| |_\/_| |_ _| |__/ |
\/ \/ |________||________| `.____ .' `.___.'|_____||_____||________|
myfile.txt
$BANNER
Welcome to my Server !
TEXT FIRST
${RED}TEXT IS RED
\e[34mTEXT IS BLUE\e[0m
TEXT THIRD
I am now looking for a prettier solution.
I am calling app.setBannerMode(Banner.Mode.OFF); in my application but I still get a banner.
My code:
SpringApplication app = new SpringApplication(MyApp.class);
app.setBannerMode(Banner.Mode.OFF);
app.setAdditionalProfiles("foobar");
Output:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.8.RELEASE)
Expected output:
(nothing)
What could be causing this?!
I'm running the following piece of bash code:
cat << END_TEXT
_ _
| | | |
__ _| |__ ___ __| |
/ _` | '_ \ / __/ _` |
| (_| | |_) | (_| (_| |
\__,_|_.__/ \___\__,_|
END_TEXT
and am getting an error:
bash: command substitution: line 1: syntax error near unexpected token `|'
bash: command substitution: line 1: ` | '_ \ / __/ _'
No need to escape backticks. Just use quoted here-doc string as:
cat <<-'END_TEXT'
_ _
| | | |
__ _| |__ ___ __| |
/ _` | '_ \ / __/ _` |
| (_| | |_) | (_| (_| |
\__,_|_.__/ \___\__,_|
END_TEXT
As per man bash:
If word is unquoted, all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion, the character sequence \<newline> is ignored, and \ must be used to quote the characters \, $, and `.
It's the backticks. Most content in a here-document is not intrepreted and used as-is, but backticks change this.
The solution: Escape them, even though it messes up the layout of your script:
cat << END_TEXT
_ _
| | | |
__ _| |__ ___ __| |
/ _\` | '_ \ / __/ _\` |
| (_| | |_) | (_| (_| |
\__,_|_.__/ \___\__,_|
END_TEXT
Were using serenity-bdd, and log analysis is important. But there is a lot of spam in the logging:
Serenety uses a lot of asci art in there logging witch is in my case waste of space and giving a lot of noice:
end2endtests | _____ _____ ____ _____ ____ _____ _ ____ _____ _____ ____
end2endtests | |_ _| ____/ ___|_ _| / ___|_ _|/ \ | _ \_ _| ____| _ \
end2endtests | | | | _| \___ \ | | \___ \ | | / _ \ | |_) || | | _| | | | |
end2endtests | | | | |___ ___) || | ___) || |/ ___ \| _ < | | | |___| |_| |
end2endtests | |_| |_____|____/ |_| |____/ |_/_/ \_\_| \_\|_| |_____|____/
end2endtests |
end2endtests |
And then on the end we get:
end2endtests | __ _____ _____ ____ _____ ____ _ ____ ____ _____ ____
end2endtests | _ \ \ |_ _| ____/ ___|_ _| | _ \ / \ / ___|/ ___|| ____| _ \
end2endtests | (_)_____| | | | | _| \___ \ | | | |_) / _ \ \___ \\___ \| _| | | | |
end2endtests | _|_____| | | | | |___ ___) || | | __/ ___ \ ___) |___) | |___| |_| |
end2endtests | (_) | | |_| |_____|____/ |_| |_| /_/ \_\____/|____/|_____|____/
end2endtests | /_/
end2endtests |
end2endtests | TEST PASSED
We do this in our Jenkins server trough a Maven command, I realy would like to reduce this noice so we have a bit less logging and sutch. I been googeling for it but havent found a clear cut answer that gave me the insight.
You need to pass -Dserenity.console.headings=minimal or -Dserenity.console.headings=normal in command line.
Or use
System.SetProperty("serenity.console.headings", "normal");
See below for more details
http://thucydides.info/docs/serenity-staging/
You can use below properties in serenity.properties file to turn off logging in reporting. (Serenity model/core version: 2.2.5)
serenity.console.headings=none to turn off the TEST STARTED banner and serenity.console.banner=none to turn off the SERENITY BDD banner.
Reference:
https://www.javadoc.io/doc/net.serenity-bdd/serenity-model/latest/net/thucydides/core/ThucydidesSystemProperty.html
I'm trying to use an ascii art string that I made with artii in a ruby program. The string can be generated using the cli as expected:
However when I try to save it as a string and either puts, p, or print it, it doesn't work. I thought it might be because the slashes need to be escaped which I've tried to do, but it looks like I'm not gsubing correctly either. How would I go about going from a working string on the cli to a working string in a ruby program that's printing the string to stdout?
banner = "
_____ _ _ _ _
| __ \ | | | \ | | | |
| |__) | _| |__ _ _ | \| | ___ | |_ ___
| _ / | | | '_ \| | | | | . ` |/ _ \| __/ _ \
| | \ \ |_| | |_) | |_| | | |\ | (_) | |_ __/
|_| \_\__,_|_.__/ \__, | |_| \_|\___/ \__\___|
__/ |
|___/
"
print banner
print banner.gsub(/\\/, "\\\\")
puts "One slash: \\"
puts "Two slashes: \\\\"
You can also use a heredoc that disables interpolation and escaping:
puts <<-'EOF'
_____ _ _ _ _
| __ \ | | | \ | | | |
| |__) | _| |__ _ _ | \| | ___ | |_ ___
| _ / | | | '_ \| | | | | . ` |/ _ \| __/ _ \
| | \ \ |_| | |_) | |_| | | |\ | (_) | |_ __/
|_| \_\__,_|_.__/ \__, | |_| \_|\___/ \__\___|
__/ |
|___/
EOF
You can't gsub backslashes because they're not there: you're trying to unspill the milk. The syntax "foo\ bar" will produce the string "foo bar", exactly like if the backslash wasn't there. It's not that the backslash is not displaying - it is never in the string in the first place, so there is nothing to gsub. You have basically two solutions: either double the backslashes in your literal by hand or by editor replacement ("foo\\ bar") before your program executes:
artii 'Ruby Note' | sed 's/\\/\\\\/g'
or read the string in from somewhere so it is not interpreted by Ruby syntax:
banner = File.read(DATA)
puts banner
__END__
_____ _ _ _ _
| __ \ | | | \ | | | |
| |__) | _| |__ _ _ | \| | ___ | |_ ___
| _ / | | | '_ \| | | | | . ` |/ _ \| __/ _ \
| | \ \ |_| | |_) | |_| | | |\ | (_) | |_ __/
|_| \_\__,_|_.__/ \__, | |_| \_|\___/ \__\___|
__/ |
|___/
will display what you want.