Friday, December 30, 2022

Disable automatic backslash insertion before $ when using auto-complete in bash

When using bash that is not configured properly, on using tab to auto-complete paths, it automatically escapes dollar symbols by inserting a backslash symbol before them, causing the commands to fail if run after auto-completion. 

For example: 

ls -l $HOME_DIR/code/wo (TAB) becomes 
ls -l \$HOME_DIR/code/workspace/ 

To stop this from occurring, you need to add this command to your  ~/.bashrc

shopt -u progcomp 

After this, source the .bashrc again and every time after you login, bash will not automatically add the backslash to escape $ symbol - viola - problem solved!

No comments:

LinkWithin

Related Posts Plugin for WordPress, Blogger...