Skip to main content

is_command_position

Function is_command_position 

Source
pub fn is_command_position(prefix: &str) -> bool
Expand description

Returns true when the characters to the left of the token we’re about to consider represent a position where a fresh command name is expected.

Command position is:

  • the very start of the line (after trimming trailing spaces), or
  • immediately after a pipeline / list operator (|, ||, &&, ;), or
  • immediately after sudo that is itself in command position (e.g. sudo gcm should still expand gcm).

Anything else (mid-arguments, after =, inside a command’s arguments) is treated as non-command-position and abbreviations should not expand.