Skip to content

Instantly share code, notes, and snippets.

@ivanrad
Created March 29, 2017 14:19
Show Gist options
  • Save ivanrad/cb99ff9e8271ac42e9e8d38a8dec4f1c to your computer and use it in GitHub Desktop.
Save ivanrad/cb99ff9e8271ac42e9e8d38a8dec4f1c to your computer and use it in GitHub Desktop.
run vim w/ sudo if necessary
#!/bin/bash
for i; do
[ -e "$i" -a ! -w "$i" ] && exec sudo vim "$@"
done
exec vim "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment