This is a discussion on [OT] A quick bash query > histories within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Off and on, over the holidays, I've been trying to find a way to save the bash history from ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Off and on, over the holidays, I've been trying to find a way to save the bash history from each tty that I open to a seperate file. I may have 9 ttys open under the same user name, however, I can find no way to save the history files according to the tty as opposed to the user....anyone know of a way. ken |
| |||
| On Wed, 04 Jan 2006 22:20:53 GMT, No_One <no_one@no_where.com> wrote: >Off and on, over the holidays, I've been trying to find a way to save the >bash history from each tty that I open to a seperate file. I may have 9 Are you relying on "!something" to work? --> alias candidate for no_one After uparrow history per terminal? --> no_one1, no_one2, ... users with appropriate symlinks to common files, directories. messy Perhaps even crazy? Grant. |
| |||
| On 2006-01-04, Grant <bugsplatter@gmail.com> wrote: > > After uparrow history per terminal? --> no_one1, no_one2, ... users > with appropriate symlinks to common files, directories. messy > Perhaps even crazy? > > Grant. Thanks, I figured out a solution last night...in the /home/kenneth/.bashrc TTYSCREEN=$(tty|sed s-/dev/tty--) HISTFILE=/home/kenneth/$TTYSCREEN.history EXPORT HISTFILE Sets a default and seperate history file for each tty I open as user kenneth ken |
| |||
| No_One <no_one@no_where.com> wrote: > TTYSCREEN=$(tty|sed s-/dev/tty--) Note: that doesn't work on X-windows "terminals" as they are pts/nn (pseudo terminal stream, with a number): $ who am i hartman pts/4 Jan 5 15:26 so NOT a tty (those are only the text console and dial-in modems. So you also must test on /dev/pts/<some number> and give it a DIFFERENT history file from the tty ones. -- ************************************************** ****************** ** Eef Hartman, Delft University of Technology, dept. EWI/TW ** ** e-mail: E.J.M.Hartman@math.tudelft.nl, fax: +31-15-278 7295 ** ** snail-mail: P.O. Box 5031, 2600 GA Delft, The Netherlands ** ************************************************** ****************** |
| |||
| On 2006-01-05, Eef Hartman <E.J.M.Hartman@math.tudelft.nl> wrote: > No_One <no_one@no_where.com> wrote: >> TTYSCREEN=$(tty|sed s-/dev/tty--) > > Note: that doesn't work on X-windows "terminals" as they are > pts/nn (pseudo terminal stream, with a number): > $ who am i > hartman pts/4 Jan 5 15:26 > so NOT a tty (those are only the text console and dial-in modems. > > So you also must test on /dev/pts/<some number> and give it a > DIFFERENT history file from the tty ones. You're right, of course...however tty will report /dev/pts/n etc. I guess the best solution would be something like: if $DISPLAY != ":0.0" parse the tty number one way else parse it another way ken |
| |||
| No_One <no_one@no_where.com> wrote: > if $DISPLAY != ":0.0" parse the tty number one way > else parse it another way Better to test on "pts" in the result from "tty", as remote logins (ssh, rsh, telnet) will also be on pts's (and the latter two do not have got DISPLAY set by default, ssh will when X-forwarding has been enabled). So something like if tty|grep -q "pts" then HISTFILE=".bash_history-pts`tty|sed "s#/dev/pts/##"` else HISTFILE=".bash_history-tty`tty|sed "s#/dev/tty##"` fi will probably work. As far as I known the old pty's (pseudo terminals, sort of a predecessor to pts streams) aren't used anymore, but if you want to make sure, you could add an extra test for those: elif tty|grep -q "pty" then HISTFILE=".bash_history-pty`tty|sed "s#/dev/pty##"` (before the "else" in the above condition). But by then it is probably useful to run "tty" just once and store the result, instead of keeping on invoking it. -- ************************************************** ****************** ** Eef Hartman, Delft University of Technology, dept. EWI/TW ** ** e-mail: E.J.M.Hartman@math.tudelft.nl, fax: +31-15-278 7295 ** ** snail-mail: P.O. Box 5031, 2600 GA Delft, The Netherlands ** ************************************************** ****************** |
| |||
| On 2006-01-06, Eef Hartman <E.J.M.Hartman@math.tudelft.nl> wrote: > No_One <no_one@no_where.com> wrote: >> if $DISPLAY != ":0.0" parse the tty number one way >> else parse it another way > > Better to test on "pts" in the result from "tty", as remote logins > (ssh, rsh, telnet) will also be on pts's (and the latter two do not > have got DISPLAY set by default, ssh will when X-forwarding has been <deleted> > > But by then it is probably useful to run "tty" just once and store > the result, instead of keeping on invoking it. I appreciate the addtional information...saved for this weekend's Linux project, one of several....again thanks. ken |
| ||||
| On 2006-01-05, No_One <no_one@no_where.com> wrote: > On 2006-01-05, Eef Hartman <E.J.M.Hartman@math.tudelft.nl> wrote: >> No_One <no_one@no_where.com> wrote: >>> TTYSCREEN=$(tty|sed s-/dev/tty--) >> >> Note: that doesn't work on X-windows "terminals" as they are >> pts/nn (pseudo terminal stream, with a number): >> $ who am i >> hartman pts/4 Jan 5 15:26 >> so NOT a tty (those are only the text console and dial-in modems. >> >> So you also must test on /dev/pts/<some number> and give it a >> DIFFERENT history file from the tty ones. > > You're right, of course...however tty will report /dev/pts/n etc. I guess the > best solution would be something like: > > if $DISPLAY != ":0.0" parse the tty number one way > else parse it another way > Definitely |
| Thread Tools | |
| Display Modes | |
|
|