Is there any way to remove ^C when you hit CTRL+C in the shell include with RHEL santiago? I have permission to edit my own .bash_profile.

share|improve this question
2  
try set echo-control-characters off – Sundeep yesterday
1  
I tried but it didn't work – Fede Gold yesterday
up vote 21 down vote accepted

Edit (or create) your ~/.inputrc file. Add a line saying

set echo-control-characters Off

This will instruct the GNU Readline library (which Bash uses) to not output (echo) any control characters to the screen. The setting will be active in all new Bash sessions thereafter (and in any other utility that uses the Readline library).

Notice that if your Unix system comes with a system-wide configuration file for the Readline library (usually /etc/inputrc), then your personal configuration file will need to include that file:

$include /etc/inputrc
set echo-control-characters Off

Another alternative is to make a personal copy of the system-wide configuration file and then modify that.

share|improve this answer
    
Hi , I tested this and its working fine but when I interrupt a running bash command it didnt worked, for example sleep 180 and press CTRL+C – Ten-Coin yesterday
    
@Ten-Coin It will only work if the command uses the Readline library unfortunately. – Kusalananda yesterday
1  
If ~/.inputrc does not already exist then simply creating the file may lose some existing settings. In my case I first noticed that ctrl+left and ctrl+right had stopped working. The fix was to start my ~/.inputrc with this line $include /etc/inputrc. It is also possible to just cp /etc/inputrc .inputrc and edit as desired. – kasperd 12 hours ago
2  
@kasperd Good point! I was not aware that adding a personal configuration file would disable the reading of the system-wide configuration file (my system doesn't have one). I will update my answer. – Kusalananda 12 hours ago

Try the following:

stty -echoctl

For an explanation see this great and detailed post from Stéphane Chazelas which also explains some other stty features.

If you want to make that change permanent (and you are using bash as implied in your question) then it's best to put into your .bashrc as noted by jlmg in the comments (so it applies to all interactive shells).

share|improve this answer
    
+1 In contrast with the readline solution, this should work for most if not all things running in the terminal. – jlmg yesterday
1  
One should probably mention that it won't work on all terminals if put in .bash_profile as that file is only parsed by login shells. It should be put in .bashrc instead, so it's read by all interactive invocations. – jlmg yesterday
    
@jlmg I would consider that to be a drawback. Personally I would prefer behavior identical to bash version 2 or 3 were you could still see if a running command was interrupted by ctrl-c. – kasperd 22 hours ago
1  
Won't this still echo the raw 0x03 byte, which may theoretically be interpreted by some terminals? It will also have side effects if you do things like running a non-readline command, pressing an arrow key will move the cursor on the screen rather than showing ^[[A – Random832 20 hours ago
    
@kasperd Well yes, but the OP didn't specify any restriction. That's why I consider this answer to be the best. Personally, I wouldn't want my ^C to ever be hidden either, neither when running a program under the shell nor on the command line. Looking back at commands I've run and seeing a ^C at the end of a command line let's me know I didn't actually run it (probably because I realized that I needed to run something else first). That's important info for me. – jlmg 3 hours ago

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.