LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-05-2008, 01:02 PM   #1
Linux von Scratchen
LQ Newbie
 
Registered: Jun 2006
Location: orbiting around Saturn
Distribution: LFS, knoppix
Posts: 16

Rep: Reputation: 0
Question colored bash sessions, each its own history


I like to run multiple xterms with a bash session in each (who doesn't?) Usually these are color-coded, e.g. -bg "#880000" for VNC sessions, a dark violet for python programming experiments, etc. These are run from a script or desktop menu, and always the same dozen colors. I create and destroy these xterms all the time. No problem so far.

I rely heavily on the up arrow key to recall past commands. But eash bash session will recall the history of some random previous bash session. What i would like: If i create a new dark violet xterm, the bash shell running in that should recall the history from the previous time i ran bash in a dark violet xterm. Meanwhile, a brown xterm's bash will recall the history of the previous time i ran bash in a brown xterm.

If there wasn't one, is okay to come up blank. If there are multiple past xterms of a certain color, i don't care if it gets confused. This is all for a convenience, not life or death.

Is this possible with some wickedly clever PS1 or .bashrc incantation, or some X windows hocus pocus? Perhaps a different xterm (i actually use rxvt) or something?
 
Old 12-07-2008, 04:20 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
I think what you want to do is to use separate history files for each of the different kind of sessions that you launch. I don't know how to set this up exactly, but I do know that it's the HISTFILE shell variable that determines the location of the history your shell uses. You can probably add it to the scripts you use to launch the sessions.

There are also some other HIST* options available for making the command history more sane, such as having it ignore duplicate entries. Check the bash man page.
 
Old 07-13-2009, 10:22 AM   #3
harryhaller
Member
 
Registered: Sep 2004
Posts: 429

Rep: Reputation: Disabled
Add this to your .bashrc file:

Code:
this_tty=`tty`                                                                          
this_tty=`basename $this_tty`                                                           
export HISTFILE=~/.bash_history.$this_tty
 
1 members found this post helpful.
  


Reply

Tags
bash, history, rxvt, xterm


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retaining Bash history from all sessions humbletech99 Programming 4 11-29-2007 05:38 PM
LXer: Keeping Command History across Multiple Sessions LXer Syndicated Linux News 1 11-07-2007 10:58 AM
need someone to look into this bash history bytez Linux - General 7 10-16-2006 10:26 PM
bash history slowly Linux - General 2 11-12-2004 11:35 AM
Bash History ukndoit Linux - Security 2 10-16-2003 09:02 AM


All times are GMT -5. The time now is 02:35 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration