Nautilus open text file with vim and make terminal persist after closing

Maybe not exactly what you want, but the following script does the thing you want, when put as a Nautilus script under the ~/.local/share/nautilus/scripts/ directory:

#!/bin/bash
file=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | head -1)
dir=$(dirname "$file")
##zenity --info --no-wrap --no-markup --title="DEBUG" --text="$file : $dir"
gnome-terminal -- /bin/bash -c "/bin/vim \"$file\" ; cd \"$dir\" ; exec /bin/bash"

Usage: Please, add the above script contents as a new file with a meaningful name (like VIM) under the ~/.local/share/nautilus/scripts/ directory. Then, using Nautilus, select a single text file, right click and on the popup menu select ScriptsVIM.

__

Disclaimer: Tested only under Ubuntu 21.10


If you want to insert the above functionality into the vim.desktop file provided by the system, you can "localize" the contents of this file by copying it to the directory ~/.local/share/applications/ and changing the line Exec=vim %F to call your custom shell script which can be created based on the script I provided above (Hint: Replace the line file=… in my script with file="$1" in your new script.)