Last active
April 3, 2018 18:09
-
-
Save floscr/49f49b701c906ec8c5085abdc2a28ff9 to your computer and use it in GitHub Desktop.
Open dropped files in NVIM in a new TMUX window
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
| 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]}` }) | |
| } | |
| } |
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
| 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