LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-08-2004, 07:45 PM   #1
vivek_kumbhar
LQ Newbie
 
Registered: Mar 2004
Posts: 2

Rep: Reputation: 0
Post 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
 
Old 04-08-2004, 09:28 PM   #2
oobe
Member
 
Registered: Sep 2003
Distribution: slackware
Posts: 85

Rep: Reputation: 16
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
 
Old 04-08-2004, 09:54 PM   #3
mikshaw
LQ Addict
 
Registered: Dec 2003
Location: Maine, USA
Distribution: Slackware/SuSE/DSL
Posts: 1,320

Rep: Reputation: 45
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
PS1="[ \@ - \u ] "
else
set_prompt
fi
"set_prompt" is a function which sets the multiline prompt.
"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.
 
Old 04-08-2004, 09:55 PM   #4
frandalla
Member
 
Registered: Oct 2003
Location: Tokyo - Japan
Distribution: Slackware
Posts: 348
Blog Entries: 1

Rep: Reputation: 37
--------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"

Last edited by frandalla; 04-08-2004 at 09:58 PM.
 
Old 04-12-2004, 07:13 AM   #5
vivek_kumbhar
LQ Newbie
 
Registered: Mar 2004
Posts: 2

Original Poster
Rep: Reputation: 0
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. "
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash programming winterhunter Linux - Newbie 6 11-26-2007 07:14 AM
Question about bash shell programming walterbyrd Linux - General 1 11-01-2005 09:42 AM
bash programming drisay Programming 6 12-20-2004 09:09 AM
Shell Programming (BASH) nny0000 Programming 2 01-13-2004 05:53 PM
bash Shell Programming Curiosity... verbal Programming 3 09-03-2002 10:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration