LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 09-22-2010, 07:47 PM   #1
ben1173
LQ Newbie
 
Registered: Sep 2010
Posts: 8

Rep: Reputation: 0
Question Configuring the primary prompt to contain the history number and exit code


Hi,

I'm just trying to configure the primary prompt to contain the last history number and exit code of the previously executed command, seperated by a ':'(with no spaces). I tried assigining variable to PS1, but I only got it to display the exit code of the previously executed command but having problem with the history number. On startup the prompt should look like:
[username@station username] 40:0 $
After every command, the history number should increase by one.
Any help would really be appreciated.

Thank you

Last edited by ben1173; 09-22-2010 at 07:48 PM.
 
Old 09-22-2010, 08:18 PM   #2
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
Check out the PROMPTING section in the bash man page. The only one I don't see there is the return code, but "\$?" seems like it works. Note the difference between \# and \!

Code:
PS1="[\u@\h \W] \!:\$? \$ "
 
1 members found this post helpful.
Old 09-22-2010, 11:16 PM   #3
ben1173
LQ Newbie
 
Registered: Sep 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Thumbs up

Thanks Meson, it worked just the way I want it. thanks again.
 
  


Reply



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
history clearance for a particular history number in linux sangupari Linux - Software 3 03-03-2010 03:08 AM
Prompt History Ace Blackwell Linux - Newbie 7 11-13-2008 11:53 AM
exit codes history guttersnipe Programming 1 07-07-2008 07:35 PM
Number of primary partitions: Still at 4? concoran Linux - Newbie 19 07-30-2007 02:10 PM
define Primary number or not... dicksonmakts Programming 9 04-04-2006 11:04 PM

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

All times are GMT -5. The time now is 01:15 PM.

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