jbrooksuk / Sublime-Evaluate

Selection evaluation in Sublime Text
https://james-brooks.uk
25 stars 6 forks source link

[Feature Request] Also wrap system call in eval #6

Closed weichuliu closed 7 years ago

weichuliu commented 7 years ago

Currently the sublime evaluate only evaluate python code.

It will though be super convenience to also evaluate system call from the same command.

For example, ipython has a nice magic that if your line start from !, it will treat the line as bash command:

In [1]: !date
Fri Jul 14 11:41:50 CDT 2017

In [2]: !TZ=UTC date
Fri Jul 14 16:41:57 UTC 2017

In [3]: !TZ=UTC date >&2
Fri Jul 14 16:42:46 UTC 2017

It will be very, very, very nice if sublime-evaluate could follow this convention to make a system call and catch stdout/stderr for user.

weichuliu commented 7 years ago

For working dir, It's reasonable either it could be the directory of the file, or be a tempdir. For untitled file, it should be a tempdir.

jbrooksuk commented 7 years ago

That would be very clever and could work like ipython.

weichuliu commented 7 years ago

Awesome!! can I consider as you are going to make it 😺 ?

weichuliu commented 7 years ago

Hi @jbrooksuk I wonder if you've already working on this issue. I kind of took a look into the code, and implemented this feature. It is pretty awesome!

The only problem is that I have to remove the progress bar because in the handle_threads method, all Popen threads has to join in order to promise the result get returned. This is a synchronous method. (it is still possible to join while updating the progress bar, but it is too tricky).

If you'd like, I will make a PR after some cleaning up.

weichuliu commented 7 years ago

How it looks like

jbrooksuk commented 7 years ago

This is amazing, please do make a PR! I've not got round to this yet.