I need to add a cmd prompt modifier, PS1="..."
within a shell script I am setting up. The issue is, I am using backtick to execute a command prior the main command:
sudo tee ~/.bashrc <<EOF
# Display absolute path in cmd line, cmds on new line
PS1='[`[ $? = 0 ] && X=2 || X=1; tput setaf $X`]h [u][`tput sgr0`]:$PWDn$ '
EOF
cat ~/.bashrc
gives:
# Display absolute path in cmd line, cmds on new line
PS1='[]h [u][]:/Users/myuser/Library/Application Support/Sublime Text 3/Packages/Usern$ '
nano ~/bashrc
gives:
PS1='[^[[32m]h [u][^[(B^[[m]:/Users/myuser/Library/Application Support/Sublime Text 3/Packages/Usern$ '
This clearly means that everything in the backtick is not properly read. How can I escape the backtick or otherwise write line that includes a backtick to a file using shell?