command property

String get command

The shell command (without trailing newline) to enqueue after a command.

Splitting token into two printf args keeps the full token out of the literal command text while still emitting it intact at runtime.

The marker line carries tab-separated fields after the token: $PWD, the git branch (empty outside a repo), a compact status (+staged ~modified ?untracked, empty when clean), and a privilege label (root when euid 0). Git branch names cannot contain tabs or spaces, so \t is a safe delimiter. Inline command substitution is used so the remote shell's environment is not polluted; the raw-string parts keep Dart from interpreting the shell's $, \, and quotes.

Implementation

String get command {
  final (a, b) = tokenHalves;
  return "printf '%s%s%s\\t%s\\t%s\\t%s\\n' '$a' '$b' "
      '$_pwd $_branch $_status $_priv';
}