Skip to content

Instantly share code, notes, and snippets.

@otmjka
Last active March 8, 2025 05:34
Show Gist options
  • Select an option

  • Save otmjka/0dae1b3ed26320910057966ca5857f84 to your computer and use it in GitHub Desktop.

Select an option

Save otmjka/0dae1b3ed26320910057966ca5857f84 to your computer and use it in GitHub Desktop.
record terminal commands history

✅ How can I display all the terminal commands I have executed in the current terminal window?

Ways to Display Executed Terminal Commands

1️⃣ Use history Command (Shows Full Command History)

history

•	This displays all previously executed commands in the current session.

2️⃣ Use fc -l (Alternative to history)

fc -l

•	Similar to history, but often includes more details.

3️⃣ Enable Real-Time Command Logging (set -o history)

If you want to see commands as they are typed:

set -o history

•	This ensures that commands are saved in history.

4️⃣ Show Only Current Session Commands

If you only want to see commands from the current terminal session, use:

history | tail -n 20 # Show the last 20 commands

5️⃣ Use script to Log Everything (Best for Debugging)

script session.log

•	This records all commands and outputs into session.log.
•	To stop recording, type:

exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment