LoginSignup
11
11

More than 5 years have passed since last update.

tmuxでコマンドの結果を一時的なpaneで表示する

Last updated at Posted at 2014-04-04

2014/11/12追記 : 現在は以下を使ってます

function s(){
    if [ $# -eq 0 ]; then
        cat > /tmp/tmux.tmp && tmux split-window "less /tmp/tmux.tmp"
    else
        REATTACH_TO_USER_NAMESPACE=`whence reattach-to-user-namespace`
        tmux split-window "$REATTACH_TO_USER_NAMESPACE $*"
    fi
}
function v(){
    if [ $# -eq 0 ]; then
        cat > /tmp/tmux.tmp && tmux split-window -h "less /tmp/tmux.tmp"
    else
        REATTACH_TO_USER_NAMESPACE=`whence reattach-to-user-namespace`
        tmux split-window -h "$REATTACH_TO_USER_NAMESPACE $*"
    fi
}

概要

man/less/grepなどの結果を見ながら作業したい場合に、出力結果を分割したpaneで表示するようにしました。

s(){
    if [ $# -eq 0 ]; then
        cat > /tmp/tmux.tmp && tmux split-window -h "less /tmp/tmux.tmp"
    else
        tmux split-window -h "$*"
    fi
}

使い方

一時paneでコマンドを実行する

$ s less path/to/file

コマンドの出力結果を一時paneで表示する

$ grep hoge path/to/file | s
11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11