Skip to content

Instantly share code, notes, and snippets.

@ggarza
Last active August 29, 2015 14:26

Revisions

  1. ggarza revised this gist Jul 28, 2015. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions sendtoiterm.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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
  2. ggarza created this gist Jul 28, 2015.
    37 changes: 37 additions & 0 deletions julia.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    " 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