LinuxCommandLibrary

n

Navigate forward in man pages

TLDR

Install a given version of node. If the version is already installed, it will be activated

$ n [version]
copy

Display installed versions and interactively activate one of them
$ n
copy

Remove a version
$ n rm [version]
copy

Execute a file with a given version
$ n use [version] [file.js]
copy

Output binary path for a version
$ n bin [version]
copy

SYNOPSIS

n [number_of_times]

PARAMETERS

number_of_times
    Optional. An integer specifying how many times to execute the previous command. The behavior varies significantly based on the 'n' command's definition. It may simply re-execute the command multiple times, or act on history entries further back.

DESCRIPTION

The n command, often an alias or shell function, provides a way to easily repeat or skip the previous command in your shell history. It's typically a shortcut to navigate and execute commands stored in the history file, making command-line interaction more efficient. While not a standard Unix utility like 'ls' or 'grep', its presence and behavior depend on the shell configuration (e.g., .bashrc, .zshrc) and user preferences. It usually mimics the behavior of pressing the up arrow and then enter to repeat the last command or some variation of it.
Commonly, "n" represents some alias for a set of keystrokes, often it is defined as 'up arrow' + 'Enter'. It may take additional arguments, like number of times to repeat the command. Since this is a command of convenience it differs widely across different linux distributions and individual configurations.

CAVEATS

The exact functionality of 'n' is highly dependent on the shell configuration. It might not be available by default, and its behavior can be customized. Some setups might interpret "n" without arguments as "next command" instead of "repeat last command", depending on custom aliases.

CHECKING THE DEFINITION

To understand how 'n' works in your environment, use the 'alias n' command in Bash or Zsh, or check your shell's configuration files (e.g., ~/.bashrc, ~/.zshrc) for its definition. For functions you can use `declare -f n`.

CUSTOMIZATION

You can easily create or modify the 'n' alias or function to match your desired behavior. For example, you could bind it to a specific key combination or make it repeat the last command a certain number of times by default.

HISTORY

The 'n' command is a relatively recent addition to the command-line toolset, typically appearing as a user-defined alias or function within shell configuration files. It wasn't a standard Unix utility from the beginning. The rise of interactive shells like Bash and Zsh, coupled with the need for faster command repetition, led to its creation. Its usage is widespread amongst users who want fast access to previously executed commands.

SEE ALSO

history(1), fc(1), !(1)

Copied to clipboard