炮弹可以更具“进攻性”吗?


10

我的Gentoo Linux是在启用了冒犯性 USE 标志的情况下编译的:

# 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中提供的链接是短暂的-我个人不使用分子动力学模拟包 -没有任何更多的那种香料中的壳(S)在一般的Linux(或UNIX)?


1-记住,cowsay可以输出任何参数,而不仅仅是运气,例如命令或脚本的输出cowsay -s $(script_in_path_or_command)。注意-s仅用于显示奶牛的外观,请参见联机帮助页。


apt-get moo和aptitude moo,aptitude moo -v,aptitude moo -vv等。但这是基于Debian的。
— Renan Vicente

1
每次跑步,都应该有一个特别的侮辱sudo su -。可能应该将root密码更改为sudo -i。
— derobert

1
顺便说一句,我想到了一种在bash中执行此操作的方法,它使用与我根据退出代码为提示符着色的特技相同的特技,并且Ubuntu的命令找不到东西...一旦回家,便会编写并发布它。
— derobert 2014年

1
不太令人反感,但是有这种感觉:sl-如果您键入“ sl”而不是“ ls”,那么蒸汽机车就会在屏幕上运转
— Ouki 2014年

1
好吧,我到家后就上床睡觉,所以直到今天才开始写这篇文章……但是作为答案发布了。
— derobert 2014年

Answers:


9

好的,通过使用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\$ "; 
`'

@illuminÉ也许您有较旧的bash版本,不确定何时添加该功能。声明-n是否有效?
— derobert 2014年

我有4.2.45(1)版本。碰巧我要更新大量的PKG。因此,稍后我将在Arch下进行尝试!谢谢,似乎很有趣,我喜欢将其混合的想法!干杯!

@illuminÉ4.3.0,Debian可能比Gentoo更新bash吗?无论如何,检查NEWS文件是4.3中的新功能。我将看到有关添加不需要新功能的版本的信息。
— derobert

@illuminÉ编辑,希望现在可以与bash 4.2一起使用。
— derobert 2014年

谢谢,这真是一团糟。很棒!但是确实是Debian。我检查了一下,确实4.3还没有做到。哦,顺便说一句,我更喜欢巴德的故事。

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.
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.