Just copy and past it.
First to install this, simple by
hyper install hyper-drop-fileand copy and paste the script.
| on alfred_script(q) | |
| write_to_file(q, "/Users/USERNAME/.hyper_plugins/hyperalfred.txt", false) | |
| tell application "Hyper" to activate | |
| end alfred_script | |
| on write_to_file(this_data, target_file, append_data) | |
| try | |
| tell application "System Events" to exists file target_file | |
| if not the result then do shell script "> " & quoted form of target_file | |
| set the open_target_file to open for access target_file with write permission | |
| if append_data is false then set eof of the open_target_file to 0 | |
| write this_data to the open_target_file starting at eof | |
| close access the open_target_file | |
| return true | |
| on error e | |
| try | |
| display dialog e | |
| close access target_file | |
| end try | |
| return false | |
| end try | |
| end write_to_file |
| -- For the latest version: | |
| -- https://github.com/vitorgalvao/custom-alfred-iterm-scripts | |
| -- Set this property to true to always open in a new window | |
| property open_in_new_window : false | |
| -- Handlers | |
| on new_window() | |
| tell application "iTerm" to create window with default profile | |
| end new_window | |
| on new_tab() | |
| tell application "iTerm" to tell the first window to create tab with default profile | |
| end new_tab | |
| on call_forward() | |
| tell application "iTerm" to activate | |
| end call_forward | |
| on is_running() | |
| application "iTerm" is running | |
| end is_running | |
| on has_windows() | |
| if not is_running() then return false | |
| if windows of application "iTerm" is {} then return false | |
| true | |
| end has_windows | |
| on send_text(custom_text) | |
| tell application "iTerm" to tell the first window to tell current session to write text custom_text | |
| end send_text | |
| -- Main | |
| on alfred_script(query) | |
| if has_windows() then | |
| if open_in_new_window then | |
| new_window() | |
| else | |
| new_tab() | |
| end if | |
| else | |
| -- If iTerm is not running and we tell it to create a new window, we get two | |
| -- One from opening the application, and the other from the command | |
| if is_running() then | |
| new_window() | |
| else | |
| call_forward() | |
| end if | |
| end if | |
| -- Make sure a window exists before we continue, or the write may fail | |
| repeat until has_windows() | |
| delay 0.01 | |
| end repeat | |
| send_text(query) | |
| call_forward() | |
| end alfred_script |