
# sudo su -
Password:
Hold it up to the light --- not a brain in sight!
Password:
選択することも可能です運命不快感の度合いに応じて:
# fortune -o kernelcookies | cowsay -b
_________________________________________
/ /* This is total bullshit: */ \
| |
\ linux-2.6.6/drivers/video/sis/init301.c /
-----------------------------------------
\ ^__^
\ (==)\_______
(__)\ )\/\
||----w |
|| ||
リンク先で提供されているフレーバーアイテム1のリストは短いので、個人的には分子動力学シミュレーションパッケージ- そういったスパイスは他にもあるのでしょうか?シェルLinux 全般 (または UNIX) ではどうでしょうか?
1-覚えておくと良いことcowsay
運勢だけでなく、コマンドやスクリプトの出力など、任意の引数を出力できます。cowsay -s $(script_in_path_or_command)
注意: -s は、ここでは単に牛の外観を示すためのものです。man ページを参照してください。
答え1
さて、PS1
と を使用するとcommand_not_found_handle
、 bash があなたを侮辱する可能性があります:
anthony@Watt:~$ . /tmp/insult.sh
anthony@Watt:~$ sl
bash: sl: command not found, incompetent spoony bard
anthony@Watt:~$ ls /wrong/path
ls: cannot access /wrong/path: No such file or directory
Learn to type, second-rate Horrified Heron.
anthony@Watt:~$
そして、これが/tmp/insult.sh
私が上で入手した情報です。
### Data ###
bash_insulter_sentences=(
'Have you considered Windows, %s?\n'
'Learn to type, %s.\n'
'Fell asleep at the keyboard again, %s?\n'
"Failure is common when you're a %s, isn't it?\n"
)
bash_insulter_subjects=(
'spoony bard' # we all played this, right?
'extra-Warty Warthog'
'Dazed Drake'
'Fidgety Fawn'
'Horrified Heron' # etc.
)
bash_insulter_adjectives=(
'incompetent ' # these have built-in spacing
'inept '
'second-rate '
'' # chance of none
''
)
### Functions to generate insults ###
bash_insulter_random_element() {
if [ ${BASH_VERSINFO[0]} -lt 4 ] || \
[ ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -lt 3 ]; then
# bash before 4.3 doesn't have -n
eval "local var=(\"\${$1[@]}\")"
else
local -n var="$1"
fi
local len=${#var[@]}
echo -n "${var[$RANDOM % len]}" # Slightly biased. Don't care.
}
bash_insulter_full_subject() {
bash_insulter_random_element bash_insulter_adjectives
bash_insulter_random_element bash_insulter_subjects
}
bash_insulter_do_insult() {
printf "$(bash_insulter_random_element bash_insulter_sentences)" "$(bash_insulter_full_subject)"
}
### set up ###
command_not_found_handle() {
echo "bash: $1: command not found, $(bash_insulter_full_subject)"
return 127
}
PS1='`
if [ 0 -ne $? -a 127 -ne $? ]; then
bash_insulter_do_insult
fi
echo "\u@\h:\w\$ ";
`'
答え2
誰かが言ったsl
最大限の予測可能性を追求するインタープリタのようなソフトウェアでは、驚き文脈上、確かに「不快」なものとして扱われます。マニュアルには適切なオプションも記載されています。
DESCRIPTION
sl is a highly advanced animation program for curing your bad habit of
mistyping.
-a An accident is occurring. People cry for help.
-l Little version
-F It flies like the galaxy express 999.
-c C51 appears instead of D51.
...そして興味深いバグ:
BUGS
It sometimes list directory contents.