Linux - SoftwareThis 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.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
After much too often wondering "hey, when did I actually start this time-consuming command?", I'm considering adding a timestamp to my bash prompt.
My first try was simple: PS1="(\A) $PS1" which gives a display like:
(16:58) exscape ~ #
However, the problem with that approach is that it displays the time when the line was written, not when the command on it was executed. So, if I run "ls" at 16:58, and get a new prompt "(16:58) ..." and then run the next command 2 hours later, it'll look like this:
(16:58) exscape ~ # new-command
I of course want the line to display the time when the command was actually run, not when the prompt appeared.
Did you try running your time-consuming commands with 'time'?
I always assumed it's just logical that it goes the way you described..time is read, command prompt written, then you are expected to type in something etc. But you never know, maybe it is possible anyway; one way I can think of (I'm not sure if it's possible in practice, but as an idea) would be to wait till something is typed in, then "cut" that (so it's not lost), rewrite the command prompt with current time in it, then "paste" (to get the updated time show up) and run the command and see how it works out..then next prompt would be printed the way you made it etc. Sounds like a lot of work, though, unless you run time-consuming things all the time and don't want to type in extra five chars
Yeah, I do use 'time', but not always. The times I forget is when I'd like this!
(And even when using time, if it's mid-operation, you still have no clue when it started.)
It definitely makes sense this way; the shell reads the clock, and prints it out. Period.
What I'd like is, I guess, a clock that updates up until you press enter, when the time you pressed enter is conserved in the history/scrollback.
I have not used this feature of zsh, but perhaps it may be of use in this situation:
Executed just after a command has been read and is about to be
executed. If the history mechanism is active (and the line was
not discarded from the history buffer), the string that the user
typed is passed as the first argument, otherwise it is an empty
string. The actual command that will be executed (including
expanded aliases) is passed in two different forms: the second
argument is a single-line, size-limited version of the command
(with things like function bodies elided); the third argument
contains the full text that is being executed.
preexec() looks like it could work, if I could only find a command to go up one line and overwrite the time. That'd mean switching to zsh, though... I've considered it for some time but I'm not sure I'm ready just yet.
HISTTIMEFORMAT only appears to be used with the "history" command, no? It doesn't change my scrollback a bit, anyhow.
Anyways, thanks for the answers, but more ones are still appreciated Especially a simple way to do "go up one line, to the beginning of the line, and type this" for preexec().
As you can see, I ran ls at 13:19, but if you look at the ls command line, it says 11:02 - since the terminal had been idle since then. I want THAT line to display the time when the command on it was executed.