4

I am new to Linux and am using Ubuntu 13.04. I have a C++ program named "dictionary" (full path: /home/anmol/Desktop/c++/dictionary), which I compiled with Code::Blocks IDE (and GCC version 4.7.3).

I have set up a custom keyboard shortcut for it by going into System Settings -> Keyboard -> Shortcuts and putting command: gnome-terminal --disable-factory -x /home/anmol/Desktop/c++/dictionary.

Now the problem I face is that the arrow keys inside the terminal aren't working... For example, whenever I press the left arrow key, I get "^[[D"... But when I run a terminal normally (by pressing Ctrl+Alt+T), the arrow keys work fine.

Now when I googled the problem, I found that this could happen if somehow the default shell had been changed from bash to sh.

So in my c++ program, to see what shell was being used as default, I added the line system("chsh"); just after the main() function and found that the default shell was bash only! Still I tried by adding the line system("chsh -s /bin/bash") but the problem persisted... (when I prefixed sudo to the command it threw an error chsh: PAM:Authentication Failure)!

Also, in the Code::Blocks Environment Settings Page, I found these 2 settings:

  • Shell to run commands in: /bin/sh -c
  • Terminal to launch console programs: gnome-terminal --disable-factory -t $TITLE -x

I changed the "Shell to run commands in": /bin/bash -c. But the problem still persisted.

Zanna
  • 72,312

1 Answers1

2

First install rlwrap tool (in Ubuntu is not installed by default) by running next command in terminal:

sudo apt-get install rlwrap

Now set up your custom keyboard shortcut using next command:

gnome-terminal --disable-factory -x bash -c 'rlwrap -a /home/anmol/Desktop/c++/dictionary'
Radu Rădeanu
  • 174,089
  • 51
  • 332
  • 407