show command history

history behaves differently in bash than it does in zsh:

In short:

  • zsh:
    • history lists only the 15 most recent history entries
    • history 1 lists all - see below.
  • bash:
    • history lists all history entries.

Sadly, passing a numerical operand to history behaves differently, too:

  • zsh:
    • history <n> shows all entries starting with <n> - therefore, history 1 shows all entries.
    • (history -<n> - note the - - shows the <n> most recent entries, so the default behavior is effectively history -15)
  • bash:
    • history <n> shows the <n> most recent entries.
    • (bash's history doesn't support listing from an entry number; you can use fc -l <n>, but a specific entry <n> must exist, otherwise the command fails - see below.)



Timestamp

In zsh, if you want to show timetstamp for each history, you can add "-i"

e.g. history -i


Reference

https://stackoverflow.com/questions/26846738/zsh-history-is-too-short

留言

這個網誌中的熱門文章

Salesforce證照考試心得 (Administrator and Advanced Administrator)

ISC2 CC (Certified in Cybersecurity Certification) 考試心得