68 lines
2.7 KiB
Markdown
68 lines
2.7 KiB
Markdown
# Create a tmux session
|
|
|
|
This script help me to create a tmux session and manage related windows, panes and commands.
|
|
|
|
## Usage
|
|
|
|
```
|
|
create-tmux-session -n <name> -i <id> -p <project> <command> <command>
|
|
|
|
-n --name <name> define a session name
|
|
-i --id <id> define a session id,
|
|
-r --repo <project> define the repo used as base directory if not defined
|
|
'ghq' and 'fzf' will be use to let you select one
|
|
|
|
<command> a command launched in the new created session. you can
|
|
use it many time.
|
|
```
|
|
|
|
## Commands
|
|
|
|
Commands create windows and panes, launch program and change current directory related to git project (managed by [ghq][ghq]).
|
|
Each command can take a parameter which is mandatpry if no default value exists.
|
|
If parameter contains spaces, must be surrounded by quotes / double quote.
|
|
|
|
* `vsplit`: split current pane vertically, parameter define the vertical size of the created pane in percent (default 20).
|
|
```bash
|
|
# split first windows, new created pane will take 50% of vertical space
|
|
create-tmux-session.sh -n mysession vsplit:50
|
|
```
|
|
* `hsplit`: split current pane horizontally
|
|
```bash
|
|
# split first windows, new created pane will take 50% of horizontal space
|
|
create-tmux-session.sh -n mysession hsplit:50
|
|
```
|
|
* `neww`: create a new windows, parameter define the new windows name (not mandatory)
|
|
```bash
|
|
# Create a new window name 'shell'
|
|
create-tmux-session.sh -n mysession -r blog neww:shell
|
|
```
|
|
* `run`: launch a command in last created element (window / pane ), parameter define command.
|
|
```bash
|
|
# Just launch ls
|
|
create-tmux-session.sh -n mysession -r blog run:ls
|
|
|
|
# This time with parameters
|
|
create-tmux-session.sh -n mysession -r blog "run:ls -la"
|
|
```
|
|
* `repo`: change current directory to given git repository in parameter.
|
|
If not parameter is provided, script will launch a menu to select one with `fzf`.
|
|
New directory will take effect for new created panes / windows after `repo` command.
|
|
```bash
|
|
# change current directory ti ephase:nix repo
|
|
create-tmux-session.sh -n mysession -r blog repo:ephase/nix neww
|
|
```
|
|
|
|
## Example
|
|
|
|
Create a new session for my blog repository, launch Neovim, split pane to create a terminal pane bellow text editor then create a new window to lanche development server
|
|
|
|
```bash
|
|
create-tmux-session.sh -n blog -r ephase/blog 'run:nvim .' vsplit neww 'run:task serve'
|
|
```
|
|
|
|
Create a new session for my blog like previous example but open new windows with my nix repository and launch Neovim
|
|
|
|
```bash
|
|
create-tmux-session.sh -n blog -r ephase/blog 'run:nvim .' vsplit neww 'run:task serve' repo:ephase/nix neww:nix 'run:nvim .'
|
|
```
|