When I run a command, I need to set some shell environment variable that holds the current command from inside ".bashrc". Actually I need to update PROMPT_COMMAND whenever a command is run, and I need the whole command line, from where I will pick relevant value.
PROMPT_COMMAND='TITLE=`echo !!`; echo $TITLE;'
I tried using echo !!
inside .bashrc but this simply gives me !!
as title. Any ideas?
ps -p $$ – Display your current shell name reliably. echo "$SHELL" – Print the shell for the current user but not necessarily the shell that is running at the movement. echo $0 – Another reliable and simple method to get the current shell interpreter name on Linux or Unix-like systems.
You can use echo $$ to get the PID of the current Bash shell you are using.
The origin of the Shell name can be traced back to the seashells that Marcus Samuel senior imported from the Far East during the late 19th Century. When his sons Marcus junior and Samuel were looking for a name for the kerosene that they were exporting to Asia, they chose Shell.
To change your shell use the chsh command: The chsh command changes the login shell of your username. When altering a login shell, the chsh command displays the current login shell and then prompts for the new one.
If you're trying to update the title of the xterm, you can use a DEBUG trap:
trap 'echo "$BASH_COMMAND"' DEBUG
See this blog post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With