dotfiles/symlinks/bin/nvimremote

26 lines
687 B
Bash
Executable File

#!/bin/sh
set -e
WINDOW_NAME=$1
SERVER_NAME=$2
FILE=$3
LINE=$4
COLUMN=$5
if test -S $SERVER_NAME; then
if [ "$XDG_SESSION_TYPE" = "x11" ]; then
/usr/bin/wmctrl -a "$WINDOW_NAME"
else
if [ "$XDG_SESSION_DESKTOP" = "sway" ]; then
swaymsg "[title=\"$WINDOW_NAME\"] focus"
elif [ "$XDG_SESSION_DESKTOP" = "gnome" ]; then
/usr/bin/wmctrl -a "$WINDOW_NAME"
fi
fi
~/.local/share/mise/shims/nvim --server $SERVER_NAME --remote $2
~/.local/share/mise/shims/nvim --server $SERVER_NAME --remote-send ":call cursor($LINE, $COLUMN)<CR>"
else
/usr/bin/alacritty --title "$WINDOW_NAME" -e /usr/bin/fish -c "nvim --listen $SERVER_NAME $2 --cmd \"call cursor($LINE, $COLUMN)\""
fi