#!/bin/bash vv() { if [ $# -eq 0 ]; then echo "Usage: vv " 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 }