Skip to content

Instantly share code, notes, and snippets.

@ggarza
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ggarza/1fd9404a1aa918f2843a to your computer and use it in GitHub Desktop.
Save ggarza/1fd9404a1aa918f2843a to your computer and use it in GitHub Desktop.
" Vim filetype plugin file
" Language: julia
autocmd! BufLeave,FocusLost * nested silent! update
nmap <buffer> <silent> <space> <esc>:call Send_to_iterm()<cr>j
noremap <leader>ae <esc>:w<cr>:call Send_input_file_to_iterm()<cr>
noremap <leader>rf <esc>:w<cr>:call New_julia_repl()<cr>
noremap <leader>pd <esc>:w<cr>:call Get_paragraph()<cr>
function! Send_to_iterm()
let current_line= getline('.')
silent exec "!osascript ~/.vim/scripts/sendtoiterm.applescript " . shellescape(current_line, 1)
endfunction
function! Send_input_file_to_iterm()
let current_file = '"' . "%:p" . '"'
let include_file = "include\(" . current_file . "\)"
let include_file = "'" . include_file . "'"
silent exec "!osascript ~/.vim/scripts/sendtoiterm.applescript " . include_file
endfunction
function! New_julia_repl()
let current_directory = "%:p:h"
silent exec "!open -a iTerm %:p:h"
silent exec "!osascript ~/.vim/scripts/sendtoiterm.applescript julia"
endfunction
function! Get_paragraph()
let start = line('.')
let end = search("^$")
let lines = getline(start, end)
for line in lines
silent exec "!osascript ~/.vim/scripts/sendtoiterm.applescript " . shellescape(line, 1)
endfor
endfunction
on run argv
set command to item 1 of argv
tell application "iTerm"
--make new terminal
tell the current terminal
--activate current session
--launch session "Default Session"
tell the last session
write text command
end tell
end tell
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment