mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-16 15:23:48 -05:00
Updated On MacVim with iTerm2 (markdown)
@@ -110,4 +110,61 @@ osascript -e \
|
||||
end run' "$1" "$PWD"
|
||||
```
|
||||
|
||||
The `tell myterm select` may be helpful when the new window opens on a monitor which does not have the main iTerm2 window. My system, running macOS Sierra, does not automatically focus the newly opened window.
|
||||
The `tell myterm select` may be helpful when the new window opens on a monitor which does not have the main iTerm2 window. My system, running macOS Sierra, does not automatically focus the newly opened window.
|
||||
|
||||
Here is JavaScript (JXA) mutation (by @chew-z):
|
||||
|
||||
```javascript
|
||||
#!/usr/bin/env osascript -l JavaScript
|
||||
// osacompile -l JavaScript -o fzf_MacVim.scpt fzf_MacVim.js
|
||||
|
||||
ObjC.import('stdlib')
|
||||
function run(argv) {
|
||||
'use strict';
|
||||
const iTerm = Application('iTerm');
|
||||
const SystemEvents = Application('System Events');
|
||||
const frontmost = Application.currentApplication(); // MacVim
|
||||
|
||||
iTerm.includeStandardAdditions = true;
|
||||
const verbose = false;
|
||||
|
||||
var args = $.NSProcessInfo.processInfo.arguments
|
||||
var argv = []
|
||||
var argc = args.count
|
||||
for (var i = 4; i < argc; i++) {
|
||||
// skip 3-word run command at top and this file's name
|
||||
// console.log($(args.objectAtIndex(i)).js)
|
||||
argv.push(ObjC.unwrap(args.objectAtIndex(i)))
|
||||
}
|
||||
if (verbose) { console.log(argv); } // print arguments
|
||||
|
||||
iTerm.activate();
|
||||
let win = iTerm.createWindowWithProfile('fzf');
|
||||
delay(0.2);
|
||||
let fzf_session = win.currentSession();
|
||||
SystemEvents.keystroke('l', {using: 'control down'}); // Clear screen from artefacts
|
||||
delay(0.2);
|
||||
let cmd1 = "cd " + argv[1]; // cd $PWD
|
||||
iTerm.write(fzf_session,{text: cmd1});
|
||||
delay(0.2);
|
||||
let cmd2 = argv[0] + " && exit"; // fzf command && exit
|
||||
iTerm.write(fzf_session,{text: cmd2});
|
||||
delay(0.2);
|
||||
while (fzf_session.isProcessing()) { // wait until fzf finished
|
||||
delay(0.2);
|
||||
}
|
||||
frontmost.activate(); // bring back MacVim
|
||||
// $.exit(0);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
You could compile script above using command ``` osacompile -l JavaScript -o fzf_MacVim.scpt fzf_MacVim.js ```
|
||||
|
||||
and then put inside fzf_MacVim.sh (your g:fzf_launcher).
|
||||
|
||||
```
|
||||
osascript -l JavaScript /path/to/fzf_MacVim.scpt "$1" $PWD
|
||||
```
|
||||
|
||||
I recommend creating separate iTerm profile for fzf interaction.
|
||||
Reference in New Issue
Block a user