-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvim
executable file
·38 lines (31 loc) · 1018 Bytes
/
nvim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
run_vim() {
# Remove script dir from $PATH to avoid infinite recursion
MYDIR="$(dirname "$(readlink -f "$0")")"
MYNAME="$(basename "$0")"
NEWPATH=$(echo "$PATH" | sed -r -e "s,${MYDIR}/?:,,")
VIMBIN=$(PATH=$NEWPATH command -v "$MYNAME")
if [[ -n $RANGER_LEVEL || -n $YAZI_LEVEL ]] \
&& [[ -n $TMUX ]] \
&& (( ${VIM_FORK:-1} == 1 ))
then
CMD="command $VIMBIN$(printf " %q" "$@")"
tmux new-window -a -c '#{pane_current_path}' "$CMD"
elif [[ -n $RANGER_LEVEL || -n $YAZI_LEVEL ]] \
&& [[ "$TERM" == xterm-kitty ]] \
&& (( ${VIM_FORK:-1} == 1 ))
then
kitty @ launch --type tab --no-response --cwd current "$VIMBIN" "$@"
else
command $VIMBIN "$@"
fi
}
if [[ -n $TMUX ]]; then
[[ -z "$SUDO_USER" ]] && OLDTITLE=$(tmux display-message -p "#{pane_title}")
run_vim "$@"
RET=$?
[[ -z "$SUDO_USER" ]] && printf '\e]0;%s\e'\\ "${OLDTITLE}"
exit $RET
else
run_vim "$@"
fi