bash shell programming
Hi,
i m trying to write a script that when run will invoke a new shell and change its prompt to system date:username thanks Vivek |
I probably cant help but it might help if yuo show people what you have already so can give you some suggestions the more info the better
cheers |
I made something similar to this for Midnight Commander because I have a multi-line prompt for regular terminals but mc only has one line of command...in other words, mc screws up the prompt..
This is what I put in .bashrc: Code:
if [ "${mcON}" = "1" ]; then "mcON" is a variable which is set from an alias or command: export mcON=1; mc -b This is not completely bug-free, though. I had to disable the mcON variable in .xinitrc in the event that I started mc in terminal before starting X. |
--------script starts here--------
#!/bin/bash PS1="\d:\u" bash --------script ends here--------- this should do, but if the PS1 variable is defined the definition on .bashrc ou .bash_profile will override this. so, you'll not be able to open another shell changing PS1's value (PS1="\d:\u" bash won't work... the profile archive will override this definition) so, instead of opening another shell you may just change actual's prompt: export PS1="\d:\u" |
Hi, the script goes like this, this script when executed will open a new shell and will have the prompt bourne$.
#!/bin/bash -x tput clear echo "This script will initiate a new shell and will carry the prompt \"bourne$\". " echo "Do you wish to initiate a new shell (y/n) : " read reply case "$reply" in y|Y ) ;; n|N ) exit ;; * ) "Invalid Argument" ; exit ;; esac if [ $reply != 'n|N' ] ; then PS1="[bourne$]\$" export PS1 sh else echo "Bye ! Have a good day. " |
All times are GMT -5. The time now is 01:12 AM. |