help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

`times` of the Parent Shell


From: shynur .
Subject: `times` of the Parent Shell
Date: Sat, 1 Nov 2025 13:40:23 +0000

I want to display the total user/sys time of the current bash session in `PS1`.
First, I made a simple attempt:

```
echo times: `times | paste --serial`  # Merge the output into a single line.
```

But something was already wrong here -- the `times` command was showing the CPU 
time of the subshell (or even a sub-subshell), not the interactive bash session.

I know there are some roundabout implementation methods.
For example, starting a pipe, outputting text to the pipe in `PROMPT_COMMAND`, 
and then reading from the pipe in `PS1`.

What I'm more curious about is:
- Does bash plan to extend the `times` command to handle such scenarios?
- Or is there a better way to implement this requirement?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]