Skip to content

Instantly share code, notes, and snippets.

@floscr
Last active April 3, 2018 18:09
Show Gist options
  • Select an option

  • Save floscr/49f49b701c906ec8c5085abdc2a28ff9 to your computer and use it in GitHub Desktop.

Select an option

Save floscr/49f49b701c906ec8c5085abdc2a28ff9 to your computer and use it in GitHub Desktop.
Open dropped files in NVIM in a new TMUX window
function run (input, parameters) {
const iTerm = Application('iTerm2')
iTerm.activate()
const windows = iTerm.windows()
var window = iTerm.currentWindow()
var tab = window.currentTab()
var session = tab.currentSession()
// Map files to quoted string array
// No arrow functions in JSA though :(
const files = input.map(function (path) {
const string = path.toString()
return "'" + string.replace("'", '"' + "'" + '"') + "'"
})
const windowName = window.name()
const fileString = files.join(' ')
// Open file in either existing vim instance in fron
// or in a new tmux window
if (windowName.indexOf('vim') === -1) {
session.write({text: `tmux new-window nvim ${fileString}` })
} else {
session.write({text: `:e ${input[0]}` })
}
}
set-option -g set-titles on
set-option -g set-titles-string "#{session_name} - #T" # Title String - Programm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment