Add support for external escape valve (^dir)

This commit makes it possible to force nu to treat a command as an external command by prefixing it with `^`. For example `^dir` will force `dir` to run an external command, even if `dir` is also a registered nu command.

This ensures that users don't need to leave nu just because we happened to use a command they need.

This commit adds a new token type for external commands, which, among other things, makes it pretty straight forward to syntax highlight external commands uniquely, and generally to treat them as special.
This commit is contained in:
Yehuda Katz
2019-08-15 15:18:18 -07:00
parent bb580a46d6
commit 0dc4b2b686
15 changed files with 228 additions and 50 deletions

View File

@ -135,6 +135,10 @@ fn paint_token_node(token_node: &TokenNode, line: &str) -> String {
item: RawToken::Bare,
..
}) => Color::Green.normal().paint(token_node.span().slice(line)),
TokenNode::Token(Tagged {
item: RawToken::External(..),
..
}) => Color::Cyan.bold().paint(token_node.span().slice(line)),
};
styled.to_string()