The L5 by default is set to remember the last 1000 commands you’ve issued, so it can be tedious to run the history
command and then look for that obscure and lengthy command you ran weeks ago, although the search box in the terminal can find it if you remember a word it contains.
I made a little utility to export the recent terminal history to a text file and list only the unique commands alphabetically, which whittles it down for easier reviewing. It consists of a short bash script, a desktop application to execute it, and an icon to launch it from the app screen.
1 The script (e.g. commands.sh
):
#!/bin/bash
# List unique recent terminal commands, remove column 1 (item number) of history file.
HISTFILE=~/.bash_history
set -o history
history | nawk '{$1="";$0=substr($0,2)}1' | sort -u > history_unique.txt
nano history_unique.txt
2 The desktop application, which should be saved to .local/share/applications
as BashHistory.desktop
(or similar):
[Desktop Entry]
Name=BashHistory
Exec=gnome-terminal -x bash "commands.sh"
StartupNotify=true
Terminal=false
Type=Application
Categories=Utilities;
Icon=/home/purism/.local/share/icons/penguin_comp.png
Name[en_US]=BashHistory.desktop
3 The icon for the app screen should be saved to local/share/icons
; I saved an image from a free clip-art website.
Top row, second from left:
Launching:
Text file is created here:
Mine contains about 250 unique commands out of the 1000 logged commands.
The launcher also opens the list of unique commands in the terminal for easy scrolling, copy, and paste.
See related thread.