Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

Screenshot:

screenshoot

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

Please guide me on how to correct this !

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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'
share|improve this answer
    
Thanks a ton!..But is there any way to do this without this tool??..That is, by editing any of the configuration files in Ubuntu..?? ( Just curious to know! ) –  Anmol Singh Jaggi Jul 9 '13 at 9:40
    
@AnmolSinghJaggi You can try a workaround starting from this post. –  Radu Rădeanu Jul 9 '13 at 9:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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