Skip to content

Instantly share code, notes, and snippets.

@brake
Created June 28, 2023 15:52
Show Gist options
  • Save brake/9872df0c531f7fcf662ddce84142288c to your computer and use it in GitHub Desktop.
Save brake/9872df0c531f7fcf662ddce84142288c to your computer and use it in GitHub Desktop.
iTerm2 open files in neovim opened in new tab
#!/usr/bin/env bash
osascript ~/Iterm2_NeoVIM.scpt "$@"
on run argv
# seem to need the full path at least in some cases
set nvimCommand to "/usr/local/bin/nvim "
set filepaths to ""
if argv is not {} then
repeat with currentFile in argv
set filepaths to filepaths & quoted form of POSIX path of currentFile & " "
end repeat
end if
if application "iTerm" is running then
tell application "iTerm"
--create window with default profile command nvimCommand & filepaths
tell current window to set tb to create tab with default profile
tell current session of current window to write text nvimCommand & filepaths & " ;exit"
end tell
else
tell application "iTerm"
tell current session of current window
write text nvimCommand & filepaths
end tell
end tell
end if
end run
@brake
Copy link
Author

brake commented Jun 29, 2023

Here is script for vifm:

#!/usr/bin/env bash
dir=$(pwd)
input=""
for s in "$@"; do
    if [[ -n "$input" ]]; then
        input="$input "
    fi
    input="$input$dir/$s"
done

osascript ~/dev/Iterm2_NeoVIM.scpt $input

Put it in $XDG_CONFIG_HOME/vifm/scripts/, make executable and add to vifmrc this line:
set vicmd=iterm2-neovim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment