Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable behavior on expression (not command) input | Unnamed alias #2411

Closed
LhKipp opened this issue Aug 25, 2020 · 5 comments
Closed
Labels
enhancement New feature or request needs-design this feature requires design Stale used for marking issues and prs as stale

Comments

@LhKipp
Copy link
Contributor

LhKipp commented Aug 25, 2020

Currently:

$ /etc

Would cd into the directory /etc
I want this behavior configurable. I would rather like the shell to ls /etc here.

As nushell is Syntax aware a mapping from
SyntaxShape1 -> alias
is possible as soon as aliases have signatures with meaning.

Describe the solution you'd like

alias --unnamed unnamed_ls [path] {ls $path}

nushell will now automatically deduct the type of path, check if one such mapping for this syntactical type exists already, and warn me if so. Otherwise typing "/etc" has the same result as "ls /etc" :)

@thegedge
Copy link
Contributor

There are two other possibilities:

  1. config set where we have a config value with a block that runs on this behaviour, or
  2. have nushell emit events that people can write scripts to hook into. Some examples of events:
    • before command execute
    • after parse
    • render prompt
    • non-executable path as command
    • exit/enter directory

We've definitely been thinking about hooks (option #2), but haven't designed anything for that yet, since our scripting support isn't top notch. #1 would be a good solution for now, and I would prefer it over a specially named alias / flag on alias because I think it's a bit easier to discover. What do you think?

@thegedge thegedge added the enhancement New feature or request label Aug 26, 2020
@LhKipp
Copy link
Contributor Author

LhKipp commented Aug 26, 2020

I agree. config set is the way to go.
I personally think when typing $ path-to-cd-to as a command (without name) to execute with path-to-cd-to as argument 1. Therefore I don't like alternative 2 that much, as it sounds more complicated.
I would like to reiterate, that I want a configuration option not only for the above mentioned use case, but a general one.
For every SyntaxShape nushell can distinguish, 1 mapping to a command to run when this SyntaxShape gets entered by the user.

$path --> cd into path
$math-expression --> drop me in a python shell and let python evaluate the expression
$column-path --> echo the value pointed to by column-path in the last table, which has been printed to the screen

This proposed idea has the shortcoming of not being able to determine between:

$ ./file --> execute file
$ path --> cd into path

As file and path are both of SyntaxShape::Path. Therefore a special rule needs to be encoded in nushell for this use case.

@thegedge
Copy link
Contributor

Thanks for expanding. That helps clarify your request.

I think that this is a fairly significant feature that would be good to explore in an RFC. I'd love to see us get rid of our hardcoded behaviour for "auto cd when directory" 🙂

@thegedge thegedge added the needs-design this feature requires design label Aug 29, 2020
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale used for marking issues and prs as stale label Jun 24, 2021
@github-actions
Copy link

github-actions bot commented Jul 7, 2021

This issue has been marked stale for more than 10 days without activity. Closing this issue, but if you find that the issue is still valid, please reopen.

@github-actions github-actions bot closed this as completed Jul 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-design this feature requires design Stale used for marking issues and prs as stale
Projects
None yet
Development

No branches or pull requests

2 participants