Skip to main content
added 69 characters in body
Source Link
Kusalananda
  • 355.7k
  • 42
  • 735
  • 1.1k

Using history expansion with ! will do this without an alias or function:

$ grunt compileModule:[something]

$ # other things

$ !grunt

The last !grunt will cause the shell to look up the last command in the command line history that starts with the string grunt and run that.

In bash:

!string

Refer to the most recent command preceding the current position in the history list starting with string.

If the shell has persistent history (usually enabled by setting HISTFILE), then this will also work across consecutive shell sessions, and depending on the shell, it may even work in concurrent sessions.

Using history expansion with ! will do this without an alias or function:

$ grunt compileModule:[something]

$ # other things

$ !grunt

The last !grunt will cause the shell to look up the last command in the command line history that starts with the string grunt and run that.

In bash:

!string

Refer to the most recent command preceding the current position in the history list starting with string.

If the shell has persistent history (usually enabled by setting HISTFILE), then this will also work across consecutive shell sessions.

Using history expansion with ! will do this without an alias or function:

$ grunt compileModule:[something]

$ # other things

$ !grunt

The last !grunt will cause the shell to look up the last command in the command line history that starts with the string grunt and run that.

In bash:

!string

Refer to the most recent command preceding the current position in the history list starting with string.

If the shell has persistent history (usually enabled by setting HISTFILE), then this will also work across consecutive shell sessions, and depending on the shell, it may even work in concurrent sessions.

Source Link
Kusalananda
  • 355.7k
  • 42
  • 735
  • 1.1k

Using history expansion with ! will do this without an alias or function:

$ grunt compileModule:[something]

$ # other things

$ !grunt

The last !grunt will cause the shell to look up the last command in the command line history that starts with the string grunt and run that.

In bash:

!string

Refer to the most recent command preceding the current position in the history list starting with string.

If the shell has persistent history (usually enabled by setting HISTFILE), then this will also work across consecutive shell sessions.