Skip to content

Instantly share code, notes, and snippets.

@papiron
Last active January 20, 2024 03:52
Show Gist options
  • Save papiron/1539a628cdada4d46054e30c082824b4 to your computer and use it in GitHub Desktop.
Save papiron/1539a628cdada4d46054e30c082824b4 to your computer and use it in GitHub Desktop.
クールなバナーを作るシェルスクリプト(MacやFreeBSD用。Linuxの場合は下記のコメントを参照。)
#!/bin/sh
[ $# -lt 1 ] && echo 'Usage: coolbanner STRING [HEIGHT]' && exit
string="$1"
if [ -z $2 ]; then
height=30
else
height="$2"
fi
banner -w $height "$string" |\
awk '{printf "%-'$height's\n", $0}' |\
tr '# ' '+-' |\
awk '
{
for(i=1;i<=NF;i++)a[NR,i]=$i
} END {
for(j=1;j<=NF;j++){
for(i=1;i<=NR;i++){
printf a[i,j]
}
print ""
}
}
' FS= |\
tail -r |\
tr '+-' "# " |\
sed 's/ *$//'
@greymd
Copy link

greymd commented Sep 24, 2016

備忘録としてインストール方法

$ curl -L https://gist.githubusercontent.com/papiron/1539a628cdada4d46054e30c082824b4/raw/bf066e21dc0b63c0825fab9186264b14b6568fa1/coolbanner> /usr/local/bin/coolbanner && chmod +x /usr/local/bin/coolbanner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment