4 ms·
Vim Sudo Write Trick (2005)
- crmd 5y ago20+ years of using Unix and vi, and still learning tricks. Love it!
- oars 5y agoVery useful, thanks for sharing.
- rgovostes 5y agoI have often wished there were something equivalent for nano. (Of course you can just save to another file and sudo mv it into place.) In the spirit of this trick, you could set the SPELL environment variable to a script that does #!/bin/sh read -p "Path: " FILENAME cat "$1" | sudo tee "$FILENAME" and then invoke it with ^T. (Bonus points: Extract the destination filename automatically from `ps -p $PPID -o command=` (somewhat portable) or /proc (Linux).)