Skip to content

Instantly share code, notes, and snippets.

@libitte
Last active July 3, 2017 02:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save libitte/a468a24f330681425e7dfd12ec4d961e to your computer and use it in GitHub Desktop.
Save libitte/a468a24f330681425e7dfd12ec4d961e to your computer and use it in GitHub Desktop.
the .vimrc file for Perl users and the .tmux file for everyone
# prefixキーをC-tに変更する
set -g prefix C-t
# C-bのキーバインドを解除する
unbind C-b
# キーストロークのディレイを減らす
set -sg escape-time 1
# ウィンドウのインデックスを1から始める
set -g base-index 1
# ペインのインデックスを1から始める
setw -g pane-base-index 1
# 設定ファイルをリロードする
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# C-t*2でtmux内のプログラムにC-aを送る
bind C-t send-prefix
# | でペインを縦に分割する
bind | split-window -h
# - でペインを横に分割する
bind - split-window -v
# Vimのキーバインドでペインを移動する
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# Vimのキーバインドでペインをリサイズする
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# マウス操作を有効にする
# setw -g mouse on
# 256色端末を使用する
set -g default-terminal "screen-256color"
# ステータスバーの色を設定する
set -g status-fg white
set -g status-bg black
# ウィンドウリストの色を設定する
setw -g window-status-fg cyan
setw -g window-status-bg default
setw -g window-status-attr dim
# アクティブなウィンドウを目立たせる
setw -g window-status-current-fg white
setw -g window-status-current-bg red
setw -g window-status-current-attr bright
# ペインボーダーの色を設定する
set -g pane-border-fg green
set -g pane-border-bg black
# アクティブなペインを目立たせる
set -g pane-active-border-fg white
set -g pane-active-border-bg yellow
# コマンドラインの色を設定する
set -g message-fg white
set -g message-bg black
set -g message-attr bright
# ステータスバーを設定する
## 左パネルを設定する
set -g status-left-length 40
set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"
## 右パネルを設定する
set -g status-right "#[fg=cyan][%Y-%m-%d(%a) %H:%M]"
## リフレッシュの間隔を設定する(デフォルト 15秒)
set -g status-interval 60
## ウィンドウリストの位置を中心寄せにする
set -g status-justify centre
## ヴィジュアルノーティフィケーションを有効にする
setw -g monitor-activity on
set -g visual-activity on
## ステータスバーを上部に表示する
#set -g status-position top
## コピーモードを設定する
### viのキーバインドを使用する
#setw -g mode-keys vi
### クリップボード共有を有効にする
#set-option -g default-command "reattach-to-user-namespace -l zsh"
### コピーモードの操作をvi風に設定する
#bind-key -t vi-copy v begin-selection
#bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
#unbind -t vi-copy Enter
#bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
colorscheme koehler
autocmd FileType * setlocal formatoptions-=ro
call plug#begin('~/.vim/plugged')
Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
call plug#end()
" http://perl-users.jp/articles/advent-calendar/2012/casual/13
augroup filetypedetect
autocmd! BufNewFile,BufRead *.t setf perl
autocmd! BufNewFile,BufRead *.psgi setf perl
autocmd! BufNewFile,BufRead *.tt setf tt2html
augroup END
autocmd BufNewFile *.pl 0r $HOME/.vim/template/perl-script.txt
autocmd BufNewFile *.t 0r $HOME/.vim/template/perl-test.txt
function! s:pm_template()
let path = substitute(expand('%'), '.*lib/', '', 'g')
let path = substitute(path, '[\\/]', '::', 'g')
let path = substitute(path, '\.pm$', '', 'g')
call append(0, 'package ' . path . ';')
call append(1, 'use strict;')
call append(2, 'use warnings;')
call append(3, 'use utf8;')
call append(4, '')
call append(5, '')
call append(6, '')
call append(7, '1;')
call cursor(6, 0)
" echomsg path
endfunction
autocmd BufNewFile *.pm call s:pm_template()
function! s:get_package_name()
let mx = '^\s*package\s\+\([^ ;]\+\)'
for line in getline(1, 5)
if line =~ mx
return substitute(matchstr(line, mx), mx, '\1', '')
endif
endfor
return ""
endfunction
function! s:check_package_name()
let path = substitute(expand('%:p'), '\\', '/', 'g')
let name = substitute(s:get_package_name(), '::', '/', 'g') . '.pm'
if path[-len(name):] != name
echohl WarningMsg
echomsg "ぱっけーじめいと、ほぞんされているぱすが、ちがうきがします!"
echomsg "ちゃんとなおしてください><"
echohl None
endif
endfunction
au! BufWritePost *.pm call s:check_package_name()
map ,pt <Esc>:%! perltidy -se<CR>
map ,ptv <Esc>:'<,'>! perltidy -se<CR>
set number
@libitte
Copy link
Author

libitte commented May 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment