Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c88e5af891 | ||
|
|
3a38e6c2d3 | ||
|
|
7d2a35635a |
@@ -1,28 +1,54 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
print("TMUX: %s" % os.getenv("TMUX", ""))
|
||||
print("SSH_TTY: %s" % os.getenv("SSH_TTY", ""))
|
||||
print("SSH_AUTH_SOCK: %s" % os.getenv("SSH_AUTH_SOCK", ""))
|
||||
print("HOME: %s" % os.getenv("HOME", ""))
|
||||
session_name = 'sshwrap'
|
||||
if len(sys.argv) > 1:
|
||||
session_name = sys.argv[1]
|
||||
|
||||
if os.getenv("TMUX") is None:
|
||||
if os.getenv("SSH_TTY") is not None:
|
||||
if os.getenv("SSH_AUTH_SOCK") is not None:
|
||||
sock_file = os.path.join(os.getenv("HOME"), ".wrap_auth_sock")
|
||||
try:
|
||||
#always try to remove
|
||||
os.remove(sock_file)
|
||||
except OSError:
|
||||
pass
|
||||
os.symlink(os.getenv("SSH_AUTH_SOCK"), sock_file)
|
||||
os.environ['SSH_AUTH_SOCK'] = sock_file
|
||||
ssh_auth_sock = '-'.join(['ssh_auth_sock', os.getenv('HOSTNAME'), session_name])
|
||||
|
||||
try:
|
||||
subprocess.check_call(["tmux", "attach-session", "-t", "sshwrap"])
|
||||
except subprocess.CalledProcessError:
|
||||
print("lets create session")
|
||||
os.environ['STY'] = "tmux-sshwrap"
|
||||
os.execlpe("tmux", "tmux", "new-session", "-s", "sshwrap",
|
||||
os.environ)
|
||||
def is_valid(key):
|
||||
if not key.startswith('PYENV'):
|
||||
return True
|
||||
|
||||
if key.endswith('_ROOT'):
|
||||
return True
|
||||
|
||||
if key.endswith('_SHELL'):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
if os.getenv("TMUX") is None:
|
||||
if os.getenv("SSH_TTY") is not None:
|
||||
if os.getenv("SSH_AUTH_SOCK") is not None:
|
||||
sock_file = os.path.join(os.getenv("HOME"), ".ssh", ssh_auth_sock)
|
||||
try:
|
||||
#always try to remove
|
||||
os.remove(sock_file)
|
||||
except OSError:
|
||||
pass
|
||||
os.symlink(os.getenv("SSH_AUTH_SOCK"), sock_file)
|
||||
os.environ['SSH_AUTH_SOCK'] = sock_file
|
||||
|
||||
try:
|
||||
subprocess.check_call(["tmux", "attach-session", "-t", session_name])
|
||||
except subprocess.CalledProcessError:
|
||||
os.environ['STY'] = "tmux-sshwrap"
|
||||
env = {k: os.environ[k] for k in os.environ.keys() if is_valid(k)}
|
||||
os.execlpe("tmux", "tmux", "new-session", "-s", session_name, env)
|
||||
else:
|
||||
print('TMUX var is set...')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("TMUX: %s" % os.getenv("TMUX", ""))
|
||||
print("SSH_TTY: %s" % os.getenv("SSH_TTY", ""))
|
||||
print("SSH_AUTH_SOCK: %s" % os.getenv("SSH_AUTH_SOCK", ""))
|
||||
print("HOME: %s" % os.getenv("HOME", ""))
|
||||
|
||||
main()
|
||||
|
||||
@@ -4,3 +4,18 @@ bind-key C-x send-prefix
|
||||
setw -g mode-keys vi
|
||||
set-option -g default-shell $SHELL
|
||||
set -g default-terminal "screen-256color"
|
||||
set -g display-panes-time 2000
|
||||
|
||||
# Copy-paste integration
|
||||
set-option -g default-command "reattach-to-user-namespace -l bash"
|
||||
|
||||
# Setup 'v' to begin selection as in Vim
|
||||
bind-key -t vi-copy v begin-selection
|
||||
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
|
||||
# Update default binding of `Enter` to also use copy-pipe
|
||||
unbind -t vi-copy Enter
|
||||
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
|
||||
# Bind ']' to use pbpaste
|
||||
bind ] run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
38
vim/vimrc
38
vim/vimrc
@@ -9,18 +9,22 @@ Plug 'mileszs/ack.vim'
|
||||
Plug 'xolox/vim-misc'
|
||||
Plug 'xolox/vim-notes'
|
||||
Plug 'scrooloose/nerdtree'
|
||||
Plug 'jistr/vim-nerdtree-tabs'
|
||||
" Plug 'jistr/vim-nerdtree-tabs'
|
||||
Plug 'mkitt/tabline.vim'
|
||||
Plug 'majutsushi/tagbar'
|
||||
Plug 'bling/vim-airline'
|
||||
Plug 'pangloss/vim-javascript'
|
||||
Plug 'mxw/vim-jsx'
|
||||
Plug 'terryma/vim-multiple-cursors'
|
||||
Plug 'ryanss/vim-hackernews'
|
||||
Plug 'benmills/vimux'
|
||||
Plug 'ivanov/vim-ipython'
|
||||
|
||||
" On-demand
|
||||
" Plug 'bufexplorer.zip', { 'on': 'BufExplorer' }
|
||||
Plug 'kien/ctrlp.vim', { 'on': 'CtrlP' }
|
||||
Plug 'airblade/vim-gitgutter', { 'on': 'GitGutterToggle' }
|
||||
Plug 'scrooloose/syntastic', { 'for': 'python' }
|
||||
|
||||
call plug#end()
|
||||
|
||||
@@ -56,6 +60,8 @@ set nowritebackup
|
||||
set nobackup
|
||||
set noswapfile
|
||||
|
||||
set nocompatible
|
||||
|
||||
set pastetoggle=<F2>
|
||||
set ruler
|
||||
|
||||
@@ -81,6 +87,16 @@ nmap <silent> <leader>n :set invrelativenumber<CR>
|
||||
set path+=**
|
||||
set wildmenu
|
||||
|
||||
" Integration with tmux+iterm2
|
||||
" https://evertpot.com/osx-tmux-vim-copy-paste-clipboard/
|
||||
set clipboard=unnamed
|
||||
|
||||
" VimuxPromptCommand
|
||||
map <Leader>vp :VimuxPromptCommand<CR>
|
||||
map <Leader>vl :VimuxRunLastCommand<CR>
|
||||
map <Leader>vi :VimuxInspectRunner<CR>
|
||||
map <Leader>vz :VimuxZoomRunner<CR>
|
||||
|
||||
" Go to tab by number
|
||||
noremap <leader>1 1gt
|
||||
noremap <leader>2 2gt
|
||||
@@ -95,13 +111,15 @@ noremap <leader>0 :tablast<cr>
|
||||
|
||||
nmap <silent> <Leader>h :nohlsearch<CR>
|
||||
nmap <silent> <Leader>b :BufExplorer<CR>
|
||||
nmap <silent> <Leader>j :%!python -m json.tool<CR>
|
||||
nmap <silent> <Leader>jd :%!python -c 'import sys, json; print(json.dumps(eval(sys.stdin.read()), indent=2))'<CR>
|
||||
nmap <F8> :TagbarToggle<CR>
|
||||
nmap <F9> :GitGutterToggle<CR>
|
||||
|
||||
iabbrev ipdb import ipdb; ipdb.set_trace()
|
||||
|
||||
" nnoremap <M-Space> :NERDTreeToggle<cr>
|
||||
nnoremap <M-Space> :NERDTreeTabsToggle<cr>
|
||||
nnoremap <M-Space> :NERDTreeToggle<cr>
|
||||
" nnoremap <M-Space> :NERDTreeTabsToggle<cr>
|
||||
|
||||
map <C-h> <C-w>h
|
||||
map <C-j> <C-w>j
|
||||
@@ -112,7 +130,6 @@ vnoremap <silent> <Leader>qs di'<ESC>pa'<ESC>
|
||||
vnoremap <silent> <Leader>qd di"<ESC>pa"<ESC>
|
||||
vnoremap <silent> <Leader>q( di(<ESC>pa)<ESC>
|
||||
vnoremap <silent> <Leader>q[ di[<ESC>pa]<ESC>
|
||||
|
||||
vnoremap <silent> <Leader>q{ di{<ESC>pa}<ESC>
|
||||
|
||||
set bg=dark
|
||||
@@ -127,7 +144,7 @@ let g:ctrlp_cmd = 'CtrlP'
|
||||
|
||||
" NETRW configuration
|
||||
let g:netrw_banner=0
|
||||
let g:netrw_browse_split=4
|
||||
" let g:netrw_browse_split=4
|
||||
let g:netrw_altv=1
|
||||
let g:netrw_liststyle=3
|
||||
|
||||
@@ -149,3 +166,14 @@ endif
|
||||
" if has("gui_running")
|
||||
" " set macvim specific stuff
|
||||
" endif
|
||||
|
||||
|
||||
" Syntastic
|
||||
set statusline+=%#warningmsg#
|
||||
set statusline+=%{SyntasticStatuslineFlag()}
|
||||
set statusline+=%*
|
||||
|
||||
let g:syntastic_always_populate_loc_list = 1
|
||||
let g:syntastic_auto_loc_list = 1
|
||||
let g:syntastic_check_on_open = 1
|
||||
let g:syntastic_check_on_wq = 0
|
||||
|
||||
Reference in New Issue
Block a user