awslabs / aws-shell

An integrated shell for working with the AWS CLI.
Apache License 2.0
7.17k stars 772 forks source link

Allow execution of shell commands [Edit: without the need for a `!` prefix] #19

Open donnemartin opened 8 years ago

donnemartin commented 8 years ago

In my use of the aws-cli/SAWS I find I'm frequently interacting with basic shell commands. aws-shell does not allow me to do this, which seems to force me to pop in/out of aws-shell.

This is supported on SAWS:

See: https://github.com/donnemartin/saws/issues/8

jamesls commented 8 years ago

The approach with the aws-shell is to differentiate the AWS CLI commands vs. other special commands by requiring non AWS CLI commands to be prefixed with !.

I borrowed this idea from ipython. If you want to run a shell command you preface it !'. You can also pipe commands if needed.

$ ipython
...
In [1]: import os; print(os.listdir('.'))
['foo.txt']

In [2]: !ls
foo.txt
 $ aws-shell
aws> !ls
foo.txt
aws> !cat foo.txt
hello world
aws> emr list-clusters
{
    "Clusters": []
}

What are your thoughts on this current approach?

donnemartin commented 8 years ago

Ah, thanks for the reminder James. I do remember you showing this to me and I thought it was interesting.

The following is just my 2 cents, very curious to hear other perspectives :)

I'm a big fan of IPython, I use it heavily with many of my Python projects. I love how IPython has added magics to build on top of what we can already do with just Python. When I'm using IPython the majority of the time I'm hacking Python code, sprinkled in with magics. I think exposing that additional functionality with magics is intuitive.

For aws-shell, IMHO I'm not sure it's an apples to apples type of comparison to bring in the magics for basic shell commands. Perhaps for aws-shell additional functionality like the handy command .edit (maybe !edit?) that might fit nicely. I think me not remembering the ! magic might be because 1) I had too much 'fun' at re:Invent the night before we discussed it...w00t Vegas! and/or 2) requiring ! to execute basic shell commands might not be discoverable.

Perhaps it's my aws-cli muscle memory kicking in. Prior to aws-shell, I had become accustomed to [frequently] firing off bash commands and aws-cli commands. I'm concerned having to now add ! for basic shell commands might be a friction point that changes the basic workflow for users.

jamesls commented 8 years ago

Definitely fair points you raise.

One minor thing worth mentioning is that because of a clear syntactic distinction between AWS CLI commands vs. shell commands (i.e does it start with !?), you didn't have to start AWS CLI commands with aws. In allowing arbitrary shell commands, I believe we'd have to lose that ability and require users to prefix every AWS CLI command with "aws". This may not be a big deal, but it is nice to save a little bit of typing on each command by banking on the assumption that in the aws-shell you're primarily interested in running AWS CLI commands.

I could go either way on this.

donnemartin commented 8 years ago

I think either approach is viable. Perhaps we should leave it as-is until we can get more feedback.

In allowing arbitrary shell commands, I believe we'd have to lose that ability and require users to prefix every AWS CLI command with "aws".

This did come to mind and might be annoying for some users.

donnemartin commented 8 years ago

This seems to be related: https://github.com/awslabs/aws-shell/issues/72