Ask for sudo/admin on files saving if required
Check for existing issues
- [X] Completed
Describe the bug / provide steps to reproduce it
Screenshot of VS Code
try editing /etc/hosts file in zed.
Environment
MacOS
If applicable, add mockups / screenshots to help explain present your vision of the feature
If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.
Zed.log
@itsbalamurali i think the best way to do it is to save a temporary copy of the modified file in a $USER repo like .cache or /tmp folder and then move it to the original file location while using pkexec . i am working on a script for this method . any help is appreciated ! this was my simple implementation in neovim (it is simple and usually barely make problems )
Heya Zed team!
Don't intent to add noise to the convo, rather just comment out this is still a pretty needed thing and I'll argue this is a bit priority, for additional context SublimeText does this as well:
btw, thanks to the ZED team, the editor is getting better and better, much appreciated.
@itsbalamurali i think the best way to do it is to save a temporary copy of the modified file in a $USER repo like .cache or /tmp folder and then move it to the original file location while using pkexec . i am working on a script for this method . any help is appreciated ! this was my simple implementation in neovim (it is simple and usually barely make problems )
This is essentially re-implementing sudoedit / sudo -e behavior
@itsbalamurali i think the best way to do it is to save a temporary copy of the modified file in a $USER repo like .cache or /tmp folder and then move it to the original file location while using pkexec . i am working on a script for this method . any help is appreciated ! this was my simple implementation in neovim (it is simple and usually barely make problems )
a way that avoids creating temporary file is piping into pkexec tee <outfile>
This is becoming my highest pain point with Zed, as I sometimes need to edit root config files and Zed seems to also be incapable of being used for sudoedit, so I have to revert back to using Vscode for such uses
edit: forget about it, sudoedit works now, hiding myself as resolved
This is becoming my highest pain point with Zed, as I sometimes need to edit root config files and Zed seems to also be incapable of being used for
sudoedit, so I have to revert back to using Vscode for such usesedit: forget about it, sudoedit works now, hiding myself as resolved
You should try the Micro editor, it can run in the zed terminal and has sudo support, and similar keybinds to vscode, so don't need to open vscode
I'd love to get this too. I want to use zed everywhere and I've tried setting
EDITOR = "zed --wait";
to use for commands like vifs, but:
❯ vifs
vifs: need to run as root
~
❯ sudo vifs
Password:
Error: Running Zed as root or via sudo is unsupported.
Doing so (even once) may subtly break things for all subsequent non-root usage of Zed.
It is untested and not recommended, don't complain when things break.
If you wish to proceed anyways, set `ZED_ALLOW_ROOT=true` in your environment.
vifs: editing error
❯ echo $ZED_ALLOW_ROOT
true
Is it even possible to edit a file that requires sudo permission? I cannot even run zed with sudo (saying it is untested and not recommended).
@Jason5Lee use sudoedit (or any tool that achieves a similar job)
Is it even possible to edit a file that requires sudo permission? I cannot even run zed with sudo (saying it is untested and not recommended).
Exact :
I have done a symlink :
sudo ln -s ~/.local/bin/zed /usr/local/bin/zed
And now when editing a file with sudo zed myFile I have this warning :
Error: Running Zed as root or via sudo is unsupported.
Doing so (even once) may subtly break things for all subsequent non-root usage of Zed.
It is untested and not recommended, don't complain when things break.
If you wish to proceed anyways, set `ZED_ALLOW_ROOT=true` in your environment.
Not sure what can break