Okay, I was stupid. I ran a bash script I got off of some forum on the internet, github I think it was, that said a cool matrix would appear in the terminal, which did happen, but it also messed up my keyboard.

In order to write just this help message, I have had to copy-paste every m,w,., and d, or else they look like this: ñ,ü,ç, and ɗ

Is there some way to undo this? I know this looks hilarious, but it really sucks to type.

I was wondering if someone that knew bash scripting could help me reverse the damage these are the problems I have in terminal.

This happens when I try to modify the script:

Found a swap file by the name ".bash matrix.swp"
          owned by: chris   dated: Thu Jan  8 00:35:25 2015
         file name: ~chris/Documents/pr0grams/bash matrix
          modified: YES
         user name: chris   host name: ubuntu
        process ID: 16416
While opening file "bash matrix"
             dated: Sun Dec  7 23:35:13 2014

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r bash matrix"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".bash matrix.swp"
    to avoid this message.

Swap file ".bash matrix.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

And this is the script itself:

colors=($green $brightgreen)
screenlines=$(expr `tput lines` - 1 + $scroll)
screencols=$(expr `tput cols` / 2 - 1)
chars=(ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ マ ミ ム メ モ ヤ ユ ヨ ラ リ ル レ ロ ワ ン)
trap "tput sgr0; clear; exit" SIGTERM SIGINT && setxkbmap gh fula
if [[ $1 =~ '-h' ]]; then
    echo "Usage:        matrix [SPACING [SCROLL]]"
    exit 0
tput cup 0 0
while :
    do for i in $(eval echo {1..$screenlines})
        do for i in $(eval echo {1..$screencols})
            do rand=$(($RANDOM%$spacing))
                case $rand in
                        printf "${colors[$RANDOM%$colorcount]}${chars[$RANDOM%$count]} "
                        printf "  "
                        printf "\033[2C"
            printf "\n"
        tput cup 0 0

It then asked to create an encryption key, and I remember it.

Please help, I know I was an idiot and should have tested it in a virtual environment first.

EDIT that formatted terribly, I found the forum I got it from: https://github.com/MKorostoff/bash-sandbox/blob/master/matrix.sh

  • I'm not sure I like the encryption key bit, but can't currently see the original script - my work environment bans it!! the .swp file is just a vi temporary file, you can delete it. – Mark Williams Jan 8 '15 at 10:17
  • Having accessed the original by circumventing the work filters, I see the original does not contain that setxkb command - do you know where that came from? Neither does it contain any sinister reference to encryption. I wonder who/what corrupted your copy of it? You probably ought to run chkrootkit NOW (ignoring Suckit which always comes up) – Mark Williams Jan 8 '15 at 10:41

The setxkbmap command is your problem - try setxkbmap gb (or us, or whatever..) to reset; you're currently in whatever gh fula represents!

  • 1
    Also the call to setxkbmap gh fula is not part of the original script, at least not the one that was linked. Searching with google for the altered line brought a few results (for example: archive.rebeccablacktech.com/g/thread/41449414) that have been altered to be more fun™. The version on github looks to be fine. – Adaephon Jan 8 '15 at 12:04
  • Yeah, I mentioned that in a comment to the OP, but I didn't like the encryption key bit & wonder if it may have been in some way subverted - if there are versions out there with keyboard mappings then that's perhaps reassuring - but not entirely! Given that there's a vi swap file in existence, the file isn't necessarily in it's original state! – Mark Williams Jan 8 '15 at 12:24

I changed the setxbmap gh fula to setxbmap us and that fixed my keyboard. Yeah it seems that I got a modified version rather than the github one. The encryption nonsense first happened when I tried to modify the characters from the Japanese symbols to English letters, and numbers but after I deleted the .swp file I never saw that nonsense again(maybe I messed up with the chmod +??? command?). I ran chkrootkit and the only one it found was the suckit one, but that just seems to be a popular false positive. I also ran rkhunter, which found nothing. Thank you to all answers, which all helped. Also thank you to whoever reformatted my original post, it was a mess beforehand.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.