Skip to content

Instantly share code, notes, and snippets.

View ssh0's full-sized avatar

Shotaro Fujimoto ssh0

View GitHub Profile
@ssh0
ssh0 / .vimrc
Last active August 29, 2015 14:24
bibcleanでbibファイルを整形【Vim】 ref: http://qiita.com/ssh0/items/3fa170023f462913f9ac
augroup filetype
autocmd!
" bib file
autocmd BufRead,BufNewFile *.bib set filetype=bib
autocmd Filetype bib let &formatprg="bibclean"
augroup END
@ssh0
ssh0 / file0.pl
Created July 1, 2015 13:38
TeXをもっと便利に使う!(自動コンパイル・部分コンパイル・分割ファイルから親ファイルのコンパイル)【Vim + vim-quickrun + latexmk】 ref: http://qiita.com/ssh0/items/e6d7540cd46fac580bc2
#!/usr/bin/perl
$latex = 'platex -interaction=nonstopmode -kanji=utf-8 %O %S';
$dvipdf = 'dvipdfmx %O -o %D %S';
$bibtex = 'pbibtex';
$pdf_mode = 3; # use dvipdf
$pdf_update_method = 2;
$pdf_previewer = "start mupdf %O %S";
# Prevent latexmk from removing PDF after typeset.
# $pvc_view_file_via_temporary = 0;
@ssh0
ssh0 / file0.txt
Last active August 29, 2015 14:23
vimperatorのプラグイン管理を考えてみた ref: http://qiita.com/ssh0/items/8251c24b51a53d5c93d4
" set the root dir for loading plugins(you can set multiple directories)
let g:plugin_loader_roots = "~/.path/to/vimperator/plugins,~/path/to/another/plugins"
" specify the plugin you use (you can omit '.js')
let g:plugin_loader_plugins = "plugin1,plugin2"
@ssh0
ssh0 / recordmydesktop.zsh_completion
Last active August 29, 2015 14:23
recordmydesktop.zsh_completion
# recordmydesktop completion {{{
#------------------------------------------------------------------------------
_recordmydesktop() {
local curcontext="$curcontext" diropts prev numopts
typeset -A opt_args
numopts="-x|-y|--channels|--freq|--buffer-size|--ring-buffer-size|--delay"
ddir="/media/shotaro/STOCK/Videos/mycast"
prev=$words[CURRENT-1]
@ssh0
ssh0 / file0.txt
Last active August 29, 2015 14:23
過去に設定して設定ファイルから消したキーバインドをちゃんと消す方法【tmux】 ref: http://qiita.com/ssh0/items/366e449ca2a3726ab7d9
<Prefix> + r => reload config file
bind-key r source-file ~/.tmux.conf \; display "Reloaded!"
@ssh0
ssh0 / file0.vim
Last active August 29, 2015 14:23
tmuxのウィンドウ名をvimの編集中のファイル名に設定する ref: http://qiita.com/ssh0/items/9300a22954cf7016279d
augroup titlesettings
autocmd!
autocmd BufEnter * call system("tmux rename-window " . "'[vim] " . expand("%:t") . "'")
autocmd VimLeave * call system("tmux rename-window zsh")
autocmd BufEnter * let &titlestring = ' ' . expand("%:t")
augroup END
@ssh0
ssh0 / img_display.py
Last active August 29, 2015 14:23
best w3m img cropping @ ranger/ext/img_display.py
def _generate_w3m_input(self, path, start_x, start_y, max_width, max_height):
"""Prepare the input string for w3mimgpreview
start_x, start_y, max_height and max_width specify the drawing area.
They are expressed in number of characters.
"""
fontw, fonth = _get_font_dimensions()
if fontw == 0 or fonth == 0:
raise ImgDisplayUnsupportedException()
@ssh0
ssh0 / img_display.py
Last active August 29, 2015 14:23
best cropping for ranger/ext/img_display.py
def clear(self, start_x, start_y, width, height):
if not self.is_initialized or self.process.poll() is not None:
self.initialize()
fontw, fonth = _get_font_dimensions()
cmd = "6;{x};{y};{w};{h}\n4;\n3;\n".format(
x = int((start_x - 0.2) * fontw),
y = int((start_y + 0.6) * fonth),
w = int((width + 0.4)* fontw),
#-------- youtube-dl completion {{{
# put this script in your .zshrc
# generated by:
# https://github.com/rg3/youtube-dl/blob/master/devscripts/zsh-completion.in
# https://github.com/rg3/youtube-dl/blob/master/devscripts/zsh-completion.py
# and modified manually
__youtube_dl() {
local curcontext="$curcontext" fileopts diropts cur prev
typeset -A opt_args
@ssh0
ssh0 / file0.txt
Created June 2, 2015 06:01
tmuxで最後のwindowの最後のpaneであるときだけ確認メッセージを出して、それ以外はそのままkillする ref: http://qiita.com/ssh0/items/2c0f0aa1f5179efb02c3
# if session has > 1 windows in current, kill-pane without confirmation.
# But confirm before killing pane when it is the last pane in the last window.
bind -n M-x if "tmux display -p \"#{session_windows}\" | grep ^1\$ && tmux display -p \"#{window_panes}\" | grep ^1\$" \
"confirm-before -p \"Kill the only pane in the only window? It will kill this session too. (y/n)\" kill-pane" \
"kill-pane"