history(n)

πŸ’– history(n) β€” the Tcl command that remembers everything you did πŸ’–

okay bestie, listen. this is the manual page for the Tcl built-in history command, and honestly? it's giving "that friend who remembers the exact thing you said three hours ago." it manipulates the history list, which is the little archive of recently-executed commands. periodt.


✨ SYNOPSIS ✨

history ?option? ?arg arg ...?

πŸ¦‹ DESCRIPTION πŸ¦‹

so the history command does one of several operations related to recently-executed commands recorded in a history list. every single one of those recorded commands is called an β€œevent”. lowkey a cute name ngl.

when you're specifying an event to the history command, you can use these forms:

  1. A number β€” if it's positive, it refers to the event with that number (all events are numbered starting at 1). if the number is negative, it selects an event relative to the current event (-1 refers to the previous event, -2 to the one before that, and so on). and 0? 0 refers to the current event. main character energy honestly.
  2. A string β€” selects the most recent event that matches the string. an event is considered to match the string either if the string is the same as the first characters of the event, or if the string matches the event in the sense of the string match command.

the history command can take any of the following forms, and you're gonna be obsessed with at least one of them:

  • history β€” same as history info, described below. it's the default, it's chill.
  • history add command ?exec? β€” adds the command argument to the history list as a new event. if exec is specified (or abbreviated, bestie, abbreviations count) then the command is also executed and its result is returned. if exec is not specified then an empty string is returned as result. slay.
  • history change newValue ?event? β€” replaces the value recorded for an event with newValue. event specifies the event to replace, and defaults to the current event (not event -1, okay, that's important, don't get it twisted). this command is intended for use in commands that implement new forms of history substitution and wish to replace the current event (which invokes the substitution) with the command created through substitution. the return value is an empty string.
  • history clear β€” erases the history list. the current keep limit is retained. the history event numbers are reset. it's giving factory reset but make it cute.
  • history event ?event? β€” returns the value of the event given by event. event defaults to -1.
  • history info ?count? β€” returns a formatted string (intended for humans to read, so like, for you and me πŸ’…) giving the event number and contents for each of the events in the history list except the current event. if count is specified then only the most recent count events are returned.
  • history keep ?count? β€” this one changes the size of the history list to count events. initially, 20 events are retained in the history list. if count is not specified, the current keep limit is returned.
  • history nextid β€” returns the number of the next event to be recorded in the history list. super useful for things like printing the event number in command-line prompts. iykyk.
  • history redo ?event? β€” re-executes the command indicated by event and returns its result. event defaults to -1. this command results in history revision: see below for details πŸ‘€

🌈 HISTORY REVISION 🌈

ngl, this part is a little lore-heavy, so sit down.

pre-8.0 Tcl had a complex history revision mechanism. the current mechanism is more limited, and the old history operations substitute and words have been removed. (as a consolation, the clear operation was added. we love a silver lining πŸŽ€)

the history option redo results in a much simpler β€œhistory revision”. when this option is invoked then the most recent event is modified to eliminate the history command and replace it with the result of the history command. if you want to redo an event without modifying history, then use the event operation to retrieve some event, and the add operation to add it to history and execute it.

bestie note: don't go looking for substitute and words. they're gone. it's a whole thing. we've moved on. πŸ•ŠοΈ

πŸ”‘ KEYWORDS πŸ”‘

event, history, record


okay that's the whole page!! this one comes from the Tcl crew β€” Tcl Built-In Commands, history(n), and if you need the receipts, it's dated Tcl. go forth and remember everything, bestie. πŸ’œβœ¨πŸ¦‹

πŸ“¦ where this page comes from