vv.sh
· 1.0 KiB · Bash
Raw
#!/bin/bash
vv() {
if [ $# -eq 0 ]; then
echo "Usage: vv <file>"
echo "Will edit with current user or sudo if needed but using nvim config of this user"
return 1
fi
vpath=$(which $EDITOR)
cfg=$(realpath ~/.config/nvim/init.lua)
#Check if sudo is needed to edit the file
if [ -w "$1" ]; then
$vpath "$1"
else
sudo $vpath -u "$cfg" "$1"
fi
}
| 1 | #!/bin/bash |
| 2 | |
| 3 | vv() { |
| 4 | if [ $# -eq 0 ]; then |
| 5 | echo "Usage: vv <file>" |
| 6 | echo "Will edit with current user or sudo if needed but using nvim config of this user" |
| 7 | return 1 |
| 8 | fi |
| 9 | |
| 10 | vpath=$(which $EDITOR) |
| 11 | cfg=$(realpath ~/.config/nvim/init.lua) |
| 12 | |
| 13 | #Check if sudo is needed to edit the file |
| 14 | if [ -w "$1" ]; then |
| 15 | $vpath "$1" |
| 16 | else |
| 17 | sudo $vpath -u "$cfg" "$1" |
| 18 | fi |
| 19 | } |
| 20 |