Wer regelmäßiger im Terminal (in meinem Fall eigentlich Bash) werkelt wird irgendwann über den Befehl
history
stolpern.
Wiki schreibt dazu
Command history is a common feature in operating system shells (such as Korn shell, Bash, cmd.exe, etc.), computer algebra programs, and other software that interacts with the user through a command line interface. Command history involves making previously-entered commands, usually up to some limit, easy to once again input to the command line. The usual method is for the user to use the Up (and Down) keyboard keys to navigate through the command history, but some programs also offer the facility for the user to press a certain function key which will show a menu of recent commands, from which the user can select one by typing a number.
Command history takes advantage of the fact the user may want to execute the same command many times, such as a developer frequently compiling and running a program, or else the new command may be a small modification of a previous one, hence necessitating little typing to modify it. It therefore saves a lot of typing for the user and increases the speed and accuracy of input to the computer.
Greift man nun regelmäßiger auf diesen Befehl zurück macht es ggf Sinn einige Feinjustierungen zu betreiben – einige kleine Ideen aus meiner
.bashprofile. Ergänzungen sind wie immer gerne gesehen.
Duplikate löschen
Da es herzlich wenig Sinn macht seine beschränkte History mit X gleichen Einträgen aufzublasen macht die Löschung von Dupletten Sinn.
# Erase duplicates
export HISTCONTROL=erasedups
History Größe definieren
Ebenso relativ einfach – wo ihr euer Limit setzen wollt hängt wohl von der Arbeitsweise ab.
# resize history size
export HISTSIZE=10000
Persistent History
Gegenseitiges überschreiben ist schon immer nervig – deshalb
# append to bash_history on quit
shopt -s histappend
History Zeitstempel
Um abschließend den Spaß noch mit einem Timestamp zu versehen
# add timestamp
export HISTTIMEFORMAT="%d/%m/%y %T "
Anwendungstipps
Bei Einstiegern mag sich nun die Frage auftun
Und jetzt ?
Ein simples
history
sollte euch nun Zugriff geben auf die gespeicherten Befehle. Will man nun z.b. den zuletzt abgesetzten Befehl erneut absetzen reicht ein simples
!!
Will man einen speziellen Eintrag über dessen Nummer erneut aufrufen geht dies via
!nummer
Fragen über Fragen
Und was sind eure History Tweaks?
Beiträge der Kategorie Randnotiz erscheinen nicht auf der Hauptseite