-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Allow reading from stdin #6161
Comments
子实又骗+1 |
Here is my workaround (I'm on OSX so might need to adjust accordingly): create ~/bin/codestdin:
Then run:
Now git log, git show, git diff pipe correctly into vscode |
Similar to @joenoon's approach, I've added this to my bash profile to wrap the function code() {
# reference to the original `code` command
_code=$(which code)
# if incoming stdin via a pipe...
if [[ -p /dev/stdin ]] ; then
tmpFile=$(mktemp -t stdin)
tee "$tmpFile" > /dev/null
$_code -w "$tmpFile" &
else
# otherwise, pass along any arguments to the original `code`
$_code "$@"
fi
} definitely not flawless, but it works for my use cases (so far). e.g.
|
For
What does not work is something like |
Hello, I wonder if redirect management in the scripts are the only thing to care for that scenario? Thank you. Good day. |
hello @pr-yemibedu, yes this should be equivalent as as I know. |
@bpasero Can we get some priority for this issue? It's been open since 2016 (that's 552 days!) and it's a bit ridiculous that VSCode still doesn't provide this extremely rudimentary shell interoperability. |
+1 |
Pushed a change to feed the contents of stdin to a file and have it open in VS Code ( This currently works by trying to detect if stdin is connected to a TTY or not, which is a bit brittle. If someone spawns VS Code without terminal emulation we might wrongly assume that data is coming in via stdin and open a tmp file. If it turns out that there are too many regressions, I might have to add a startup argument ( If someone has a better idea how to detect if data is flowing in via stdin let me know. |
This is great to see! Thanks so much!
Is Atom's implementation the same? |
@jakearchibald as far as I know, Atom does not support this. |
@bpasero huh, I really thought it did, but local tests (and atom/atom#11184) suggest not. Anyway, thanks again! |
Hello, |
@pr-yemibedu done |
Thanks for the feature, very nice. Just my 2 cents on feedback, the implied Regardless, cheers and thanks for the work! |
@mrmark the calling process is waiting because it is not clear how long data is being sent to |
Hrm, wasn't aware that was even possible. I feel like most commands I pipe complete then output is sent to the editor. |
A terminal can have a specific encoding set which my solution did not yet account for. I pushed a change to try a little bit of terminal encoding guessing but I think the solution is not ideal. If someone has a better idea (@Tyriar ?), let me know:
This will not help if you change the encoding of the terminal ad-hoc as that does not seem to cause any configuration change that the On Windows I see the |
This is very useful when working with the commandline, and to pass the result directly into the editor. It's especially useful for getting a file out of git's history, eg:
git show branch-name:path/to/file.js | code
FWIW, this works in Sublime.
The text was updated successfully, but these errors were encountered: