Created
August 8, 2023 14:29
-
-
Save softwaredoug/c4895d6b3a450129d5b73f18e2a13152 to your computer and use it in GitHub Desktop.
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
# Use a neovim session per working directory | |
#!/bin/bash | |
(which nvr > /dev/null) || pip3 install neovim-remote | |
working_dir_slug() { | |
CWD=$(pwd) | |
CWD=${CWD//\//_} | |
echo $CWD | |
} | |
SOCKET_FOR_WORKING_DIR="/tmp/$(working_dir_slug)_neovim_socket" | |
if [ -S "$SOCKET_FOR_WORKING_DIR" ]; then | |
echo "Socket found at $SOCKET_FOR_WORKING_DIR" | |
nvr -cc split --servername "$SOCKET_FOR_WORKING_DIR" --remote-wait +'set bufhidden=wipe' $1 | |
else | |
echo "Start at $SOCKET_FOR_WORKING_DIR" | |
nvim --listen "$SOCKET_FOR_WORKING_DIR" $1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment