How does history work in fish shell?

7,704

The history command here isn't bash-compatible, it's just displaying it in a pager (e.g. less).

To select an old command, you'll probably want to enter the part you remember right into the commandline, press up-arrow until you have found what you want and then press enter to execute.

E.g. on my system I enter mes, press up and rm -I meson.build appears (with the "mes" part highlighted). I then press enter and it executes.

Share:
7,704

Related videos on Youtube

Philip Kirkbride
Author by

Philip Kirkbride

Updated on September 18, 2022

Comments

  • Philip Kirkbride
    Philip Kirkbride over 1 year

    I'm a bash user, starting a new job at a place where people use fish shell.

    I'm looking at the history command which I often use in bash. When I use it in fish I get a long list of my history which I can scroll up and down on with the arrow keys.

    There are no numbers like in bash and pressing enter is the same as the down key.

    How can I run a past command with fish shell's history?

  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' about 7 years
    But what if you don't remember the command, but read your history and find it out? E.g. “whichever command I ran immediately after that one” or “that command contained the name of a Chinese emperor but I don't remember which one”.
  • Philip Kirkbride
    Philip Kirkbride about 7 years
    Thanks faho and yes @gilles another big downside is that you can't really use a double grep.
  • Zanchey
    Zanchey about 7 years
    You can search the history with the usual pager command (usually '/'), or pipe it through grep or other commands. Like git, or systemctl, the pager is only used if the output is directly to a TTY.
  • dave
    dave over 4 years
    Documentation can be found here: fishshell.com/docs/current/commands.html#history