You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which sets the prompt, splits the terminal window using tmux and displays command history
251
-
in the upper panel. Requirement: [tmux](https://github.com/tmux/tmux/wiki)
252
-
253
-
**Better (bash)**: This prints the output before the command is run,
254
-
instead of after. Tail with `tail -f ~/demos.out`.
255
-
256
-
```
257
-
BASH_LOG=~/demos.out
258
-
bash_log_commands () {
259
-
# https://superuser.com/questions/175799
260
-
[ -n "$COMP_LINE" ] && return # do nothing if completing
261
-
[[ "$PROMPT_COMMAND" =~ "$BASH_COMMAND" ]] && return # don't cause a preexec for $PROMPT_COMMAND
262
-
local this_command=`HISTTIMEFORMAT= history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//"`;
263
-
echo "$this_command" >> "$BASH_LOG"
264
-
}
265
-
trap 'bash_log_commands' DEBUG
266
-
```
267
-
268
-
**Better (zsh)**: This works like above, with zsh. Tail with `tail -f
269
-
~/demos.out`.
270
-
271
-
```
272
-
preexec() { echo $1 >> ~/demos.out }
273
-
```
274
-
275
-
**Better (fish)**: This works like above, but for fish. Tail with
276
-
`tail -f ~/demos.out`.
277
-
278
-
```
279
-
function cmd_log --on-event fish_preexec ; echo "$argv" >> ~/demos.out ; end
280
-
```
281
-
282
-
**Better (tmuxp)**: This will save some typing. [TmuxP](https://tmuxp.git-pull.com/) is a Python program (`pip install tmuxp`) that gives you programmable `tmux` sessions. One configuration that works (in this case for `fish` shell):
283
-
284
-
```yaml
285
-
session_name: demo
286
-
windows:
287
-
- window_name: demo
288
-
layout: main-horizontal
289
-
options:
290
-
main-pane-height: 7
291
-
panes:
292
-
- shell_command:
293
-
- touch /tmp/demo.history
294
-
- tail -f /tmp/demo.history
295
-
- shell_command:
296
-
- function cmd_log --on-event fish_preexec ; echo "$argv" >> /tmp/demo.history ; end
297
-
```
298
-
299
-
**Windows PowerShell**: In [Windows Terminal](https://docs.microsoft.com/en-us/windows/terminal/),
300
-
a split can be made by pressing `CTRL+SHIFT+=`. Then, in one of the splits, the following
301
-
PowerShell command will start tracking the shell history:
0 commit comments