sh 脚本Tmux

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 脚本Tmux相关的知识,希望对你有一定的参考价值。

#!/bin/sh

# put this on .tmux.conf
# set-window-option -g automatic-rename off
# set-option -g allow-rename off

# Save the session in vim:
# :mks! $css

# Close Tmux session:
# tmux kill-session

# Put this in your .bashrc or .zshrc file, Uncomment the lines with export
# Path of Projects Folder ;b
#export PROJECTS_FOLDER=~/Projects/Rails/
# the Sessions script folder
#export SESSIONS_FOLDER=~/Scripts/sessions/

open_project(){
    cd $PROJECTS_FOLDER${SESSION_NAME}/
    # Path of vim session file
    export css=${SESSIONS_FOLDER}${SESSION_NAME}.vim
    # if the session is already opened
    tmux has-session -t ${SESSION_NAME} &>/dev/null
    if [ $? != 0 ] # If not, do
    then
      # A Terminal on :1
      tmux new-session -s ${SESSION_NAME} -n Terminal -d
      # A Vim, that make a session on openning and autoload that
      tmux new-window -n Vim -t ${SESSION_NAME} 'vim -c "if file_readable(\"$css\")|source $css|else|mks $css|source $css|endif"'
      # A Rails server
      tmux new-window -n Server -t ${SESSION_NAME} 'rails s'
      # A Rails console
      tmux new-window -n Console -t ${SESSION_NAME} 'rails c'
      # Back to Terminal
      tmux select-window -t ${SESSION_NAME}:1
    fi
    # Load tmux session
    tmux attach -t ${SESSION_NAME}
}

ALL_PROJECTS=($(ls ${PROJECTS_FOLDER}))
for i in "${ALL_PROJECTS[@]}"
do
    echo $i
    if [ "$i" == "$1" ] ; then
        SESSION_NAME=$1
        open_project
    fi
done

以上是关于sh 脚本Tmux的主要内容,如果未能解决你的问题,请参考以下文章

sh CentOS的手动安装TMUX脚本

sh 用于安装没有root访问权限的tmux的bash脚本

sh 用于安装没有root访问权限的tmux的bash脚本

sh 用于安装没有root访问权限的tmux的bash脚本

如何在tmux窗口中启动脚本后自动终止ssh连接?

sh ubuntu 16.04的脚本,自动安装zsh,oh-my-zsh,tmux和powerline,以及配置powerline