I'm in the process of writing a shell script which sets up my osx machine exactly how I like each time I get a new machine. One piece of command line sugar I really like is the 'up arrow bash history search'. As the ask ubuntu post says, adding the line:
bind '"\e[A":history-search-backward'
to my ~/.bashrc
will do this for me, but, I'd like this automated from my script...
To achieve it I've had the most success with printf, but I need to escape the quotes and escape sequence immediately after bind ('"\e
), something like:
printf "bind \'\"\\e[A\":history-search-backward\'" >> ~/.bashrc
but in that example the escape sequence doesn't escape so in my ~/.bashrc
i get the line:
bind '"^[[A":history-search-backward'
I've tried numerous different combinations of quoting/escaping/interpolation and had little success, does anyone have some character escaping foo that could achieve this or even just an explaination on why this won't work, google is particularly thin on the ground for this especially around the \e
escaping.