Faccio un po’ di trackbacking dal blog di lord_dex (leggetelo ogni tanto, scrive roba interessante) per segnalarvi come aggiuntere date and time nella bash history.
Basta semplicemente fare l’export della variabile HISTTIMEFORMAT indicando il timestamp che più preferite.
Ecco l’esempio riportato da lui:
?Mostra codice BASH
1 | export HISTTIMEFORMAT="%h/%d - %H:%M:%S " |
Io vi consiglio:
?Mostra codice BASH
1 | export HISTTIMEFORMAT="[%d %h - %H:%M:%S] " |
tanto per rendere un po’ più leggibile l’output (ovviamente giorno e mese potrebbero essere superflui
, dipende da voi).
History inizierà a riportare subito la modifica, in bash_history verrà invece salvato il tempo Unix di quando è stato eseguito il comando.
Altre variabili di interesse potrebbero essere…
| HISTCMD | The history number, or index in the history list, of the current command. |
| HISTCONTROL | Defines whether a command is added to the history file. |
| HISTFILE | The name of the file to which the command history is saved. The default value is ~/.bash_history. |
| HISTFILESIZE | The maximum number of lines contained in the history file, defaults to 500. |
| HISTIGNORE | A colon-separated list of patterns used to decide which command lines should be saved in the history list. |
| HISTSIZE | The maximum number of commands to remember on the history list, default is 500. |
Insomma… c’è di tutto per una buona personalizzazione…
