Created
July 10, 2025 10:15
-
-
Save manno/eda4cea38f50509a5f3c25bd278e322c to your computer and use it in GitHub Desktop.
vi-d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ -z "$1" ]; then | |
| echo "Usage: $0 [-d <left-dir>] <right-dir>/<file> [<left-dir>]" | |
| exit 1 | |
| fi | |
| while getopts ":d:" opt; do | |
| case $opt in | |
| d) | |
| left="$OPTARG" | |
| ;; | |
| \?) | |
| echo "Invalid option: -$OPTARG" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| shift $(expr $OPTIND - 1 ) | |
| right="$1" | |
| if [ -z "$left" ]; then | |
| left=${2:-.} | |
| fi | |
| if [ ! -e "$right" ]; then | |
| echo "Error: '$right' does not exist." | |
| exit 1 | |
| fi | |
| if [ ! -d "$left" ]; then | |
| echo "Error: '$left' is not a directory." | |
| exit 1 | |
| fi | |
| file=$(basename "$right") | |
| nvim -d "$left"/"$file" "$right" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment