Giter VIP home page Giter VIP logo

tmuxifier's Introduction

Tmuxifier Build Status

Tmuxify your Tmux. Create, edit, manage and load complex Tmux session, window and pane configurations with ease.

In short, Tmuxifier allows you to easily create, edit, and load "layout" files, which are simple shell scripts where you use the tmux command and helper commands provided by tmuxifier to manage Tmux sessions and windows

Window Layouts

Window layouts create a new Tmux window, optionally setting the window title and root path where all shells are cd'd to by default. It allows you to easily split a window into specifically sized panes and more as you wish.

You can load a window layout directly into your current Tmux session, or into a session layout to have the window created along with the session.

Session Layouts

Session layouts create a new Tmux session, optionally setting a session title and root path where all shells in the session are cd'd to by default. Windows can be added to the session either by loading existing window layouts, or defined directly within the session layout file.

Example

Given we have a window layout file called example.window.sh which looks like:

window_root "~/Desktop"
new_window "Example Window"
split_v 20
run_cmd "watch -t date"
split_h 60
select_pane 0

You can then load that window layout into a new window in the current tmux session using:

tmuxifier load-window example

Which will yield a Tmux window looking like this:

example

Installation

Manual

Clone the repo to your machine:

git clone https://github.com/jimeh/tmuxifier.git ~/.tmuxifier

Then add $HOME/.tmuxifier/bin to your PATH to make the tmuxifier executable available to you:

In bash & zsh:

export PATH="$HOME/.tmuxifier/bin:$PATH"

In tcsh:

set path = ( "~/.tmuxifier/bin" $path )

In fish:

set -gx PATH "~/.tmuxifier/bin" $PATH

Custom Installation Path

To install Tmuxifier somewhere else than the suggested ~/.tmuxifier, simply clone the repository to your custom location, and ensure the bin folder is added to your PATH making the tmuxifier executable available to you.

TPM

You can also install and update Tmuxifier with TPM:

set -g @plugin 'jimeh/tmuxifier'

Trigger TPM's install command with prefix + I to install Tmuxifier to TPM's plugin directory (default is $HOME/.tmux/plugins).

To use the tmuxifier command, you will need to add the bin directory to your PATH. If you are using the default TPM plugin directory, the bin directory will be $HOME/.tmux/plugins/tmuxifier/bin.

Setup

In bash & zsh:

And add the following to your ~/.profile, ~/.bash_profile, ~/.zshrc or equivalent:

eval "$(tmuxifier init -)"

In tcsh:

Add the following to your ~/.cshrc, ~/.tcshrc or equivalent:

eval `tmuxifier init -`

In fish:

And add the following to your ~/.config/fish/config.fish or equivalent:

eval (tmuxifier init - fish)

Custom Tmux Arguments

If you need to pass custom arguments to tmux itself, you can do so by setting the TMUXIFIER_TMUX_OPTS environment variable. For example to set custom arguments globally:

export TMUXIFIER_TMUX_OPTS="-L my-awesome-socket-name"
eval "$(tmuxifier init -)"

And/or specify dynamically when calling tmuxifier:

TMUXIFIER_TMUX_OPTS="-L other-socket" tmuxifier load-session welcome

Updating

cd ~/.tmuxifier # or where you've cloned tmuxifier to
git pull

Usage

Note: This section needs expanding upon.

For a quick reference on available commands and their aliases, please run:

tmuxifier help

Tmuxifier doesn't come with any layouts, so you'll want to create your own window and session layout files. New layout files are populated with examples and comments explaining what things do. Also, having a look at the examples directory will also give you a good idea.

Window Layouts

First off you'll want to define a window layout:

tmuxifier new-window my-awesome-window

This will create a new layout file called my-awesome-window.window.sh in your $TMUXIFIER_LAYOUT_PATH, and open it with the editor defined in $EDITOR. Customize it as you wish, and save.

You can now load my-awesome-window with the following command:

tmuxifier load-window my-awesome-window

You should now have a new Tmux window open created from your custom and awesome window layout.

Session Layouts

To create your first session layout, run:

tmuxifier new-session my-awesome-session

Same deal as with creating a new window, except the filename ends with .session.sh instead of .window.sh, and the file's pre-populated content looks different. To have your awesome window loaded, add load_window "my-awesome-window" to the session layout next to existing examples.

To load the session layout simply run:

tmuxifier load-session my-awesome-session

You'll now have a new Tmux session with your previously defined awesome window in it.

Configure & Customize

Custom Layouts Path

You can customize the layouts directory used by Tmuxifier by setting $TMUXIFIER_LAYOUT_PATH.

export TMUXIFIER_LAYOUT_PATH="$HOME/.tmux-layouts"

Disable Shell-Completion

Tmuxifier comes with shell-completion for bash, zsh, tcsh, and fish. If for any reason you need to disable it, just set $TMUXIFIER_NO_COMPLETE.

export TMUXIFIER_NO_COMPLETE=1

Tips

iTerm2 Integration

Tmuxifier supports iTerm2's Tmux integration. It can be used in two ways:

  • Passing -CC as a second argument to the load-session command. For example:

        tmuxifier load-session my-awesome-session -CC
    
  • Setting the TMUXIFIER_TMUX_ITERM_ATTACH environment variable to -CC before calling the load-session command.

Inspiration

  • Tmuxifier is largely inspired by Tmuxinator.
  • The shell script structure and shell-completion setup is heavily inspired/ripped from the internals of rbenv.

Tmuxifier vs. Tmuxinator

Though Tmuxifier is largely inspired by the excellent Tmuxinator project, it does set itself apart in a number of ways:

  • Uses shell scripts to define Tmux sessions and windows instead of YAML files. The benefit is total control over Tmux, but the definition files are more complicated to work with.
  • Instead of using a "project" concept, Tmuxifier uses a concept of "sessions" and "windows" just like Tmux itself. This allows you to load a whole session with multiple pre-defined window configurations, or just load a single window configuration into your existing session.
  • Tmuxifier is a set of shell scripts, meaning it doesn't require Ruby to be installed on the machine.

Todos

  • Improve Readme, specially Usage section.
  • Write up a detailed reference for all available layout helper functions.

License

(The MIT license)

Copyright (c) 2014 Jim Myhrberg.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

tmuxifier's People

Contributors

0inp avatar blueyed avatar fomichev avatar fritzgrabo avatar gabyx avatar greeneca avatar gryftir avatar jimeh avatar joaopedroaat avatar leesei avatar limeyd avatar mlavi avatar mralexlau avatar raulbrito avatar shalecraig avatar stephenmckinney avatar trekdemo avatar trobrock avatar wikimatze avatar xsteve avatar yuki-inoue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmuxifier's Issues

Can not create session

After created window
I cd to the working directory and
$ tmuxifier new-session my-awesome-session
Then error:

tmuxifier-new-session: line 47: /Users/kul/.tmux-layouts/my-awesome-session.session.sh: No such file or directory

Delay before running commands

I want to run zeus, and then the rails server against zeus.

If I just use the zeus server command, it gets ran too quickly and doesn't think zeus is running yet!

run_cmd "zeus start" 1
run_cmd "zeus s" 2

So, is using a sleep in the command the only way of fixing it?

run_cmd "zeus start" 1
run_cmd "sleep 1; rails s" 2

ability to pass filename to tmuxifier

So currently you can open windows and sessions, but you have to hardcode any files you want to open in, say, vim. So you can't use the same setup for different files, or vary the setup based on passed in filenames. So I can't, for example, use the same setup for different c coding projects. The ability to pass filenames would be very helpful. I may be able to figure out how to modify bash to do what I want (and if I do, I'll submit a pull request) but I don't know the other shell languages.

run_cmd in __go_to_window_or_session_path() is trampling over command given to new_window

__go_to_window_or_session_path() is clobbering the command supplied to new_window. The cd and clear commands being run in this function are run after the window command.

For example, consider the following line in mysession.session.sh, which creates a window that runs re.pl, a Perl REPL:

new_window "repl" re.pl

And the resultant window:

cd "/home/zeroknight/Projects/blah"                     
clear                                                      
$ String found where operator expected at (eval 324) line 5, near "cd "/home/zeroknight/Projects/blah""             
        (Do you need to predeclare cd?)                    
Compile error: syntax error at (eval 324) line 5, near "cd "/home/zeroknight/Projects/blah""                        
BEGIN not safe after errors--compilation aborted at (eval 324) line 5, <FIN> line 1.                                   
$ Compile error: Bareword "clear" not allowed while "strict subs" in use at (eval 325) line 5, <FIN> line 2.           
$   

As you can see, the two run_cmd bits are being run inside the REPL, rather than in the shell before the REPL is launched. Perhaps this is related to #80?

Add set_layout helper to allow easy use of Tmux's select-layout command

Example with layout string copied from the list-windows command:

set_layout "61de,238x73,0,0{118x73,0,0,1,119x73,119,0[119x36,119,0,2,119x36,119,37,3]}"
select_pane 0
run_cmd "htop"
select_pane 1
run_cmd "sensors"
select_pane 2

This could be useful when relying on one Tmux's five built-in layouts, or if often making small adjustments to a specific window layout. Instead of adjusting split_v and split_h commands, you can just get the layout string from tmux list-windows and paste it in.

No command ^L found.

Hello,
I tried out the default window config.
But i received an error :

$ vim ew mywin
...
run_cmd 'date' 1

$ tmux
$ tmuxifier w mywin

~$ ^Ldate
No command '
date' found, did you mean:
Command 'hdate' from package 'libhdate1' (main)
Command 'sdate' from package 'sdate' (universe)
Command 'rdate' from package 'rdate' (main)
Command 'idate' from package 'itools' (universe)
Command 'date' from package 'coreutils' (main)

date: command not found

in config file , every run_cmd command is incorporate the "^L" key.

The command "tmuxifier-tmux resize-pane" is not working in tmux 2.1

I have some window definition files with many instances of the tmuxifier-tmux resize-pane command, for example:

split_h
select_pane 1
tmuxifier-tmux resize-pane -L 50

These commands no longer work after updating from tmux 1.8 to tmux 2.1. I have reverted to specifying a size in the split_ commands, which is less than ideal for more complex window configurations.

Pass arguments to tmux?

I seriously love tmuxifier, but one thing is killing me: I usually have tmux aliased to tmux -2 to give me 256 colour support. For whatever reason, tmuxifier doesn't pick up the alias in my .bashrc, so I'd like to be able to set an option somewhere to set the -2 flag.

Load tmuxifier session via ssh command fails

Hey,

I'm trying to load a session on a remote machine via ssh, i.e. I want to automatically load a session when I connect.

ssh my_host -t tmuxifier load-session my_session

But when I try this I get the error:

bash: tmuxifier: command not found

When I manually connect to the machine I can execute tmuxifier. I guess that .bashrc/.profile are not loaded upon the ssh connection and therefore tmuxifier is not available. But I don't have any idea how to fix this.

Errors on setup when using eval within fish

Not sure if this related to #40 :

$ eval (tmuxifier init -)
fish: Unknown command 'export'
- (line 1): begin; export TMUXIFIER="/Users/ian/.tmuxifier"; source "$TMUXIFIER/init.sh";
                   ^
in . (source) call of file '-',
        called on standard input,

source: Error encountered while sourcing file '/init.sh':
source: No such file or directory

And when it's added to the ~/.config/fish/config.fish I get the following output on every new fish shell :

- (line 1): begin; export TMUXIFIER="/Users/ian/.tmuxifier"; source "$TMUXIFIER/init.sh";
                   ^
in . (source) call of file '-',
        called on line 34 of file '/Users/ian/.config/fish/config.fish',

in . (source) call of file '/Users/ian/.config/fish/config.fish',
        called on standard input,

fish: The '$' character begins a variable name. The character '{', which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.
/Users/ian/.tmuxifier/init.sh (line 2): if [ -z "${TMUXIFIER}" ]; then
                                                ^
in . (source) call of file '/Users/ian/.tmuxifier/init.sh',
        called on line 1 of file '-',

in . (source) call of file '-',
        called on line 34 of file '/Users/ian/.config/fish/config.fish',

in . (source) call of file '/Users/ian/.config/fish/config.fish',
        called on standard input,

fish: The '$' character begins a variable name. The character '{', which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.
/Users/ian/.tmuxifier/init.sh (line 3):   export TMUXIFIER="${HOME}/.tmuxifier"
                                                 ^
in . (source) call of file '/Users/ian/.tmuxifier/init.sh',
        called on line 1 of file '-',

in . (source) call of file '-',
        called on line 34 of file '/Users/ian/.config/fish/config.fish',

in . (source) call of file '/Users/ian/.config/fish/config.fish',
        called on standard input,

fish: The '$' character begins a variable name. The character '{', which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.
/Users/ian/.tmuxifier/init.sh (line 5):   export TMUXIFIER="${TMUXIFIER%/}"
                                                 ^
in . (source) call of file '/Users/ian/.tmuxifier/init.sh',
        called on line 1 of file '-',

in . (source) call of file '-',
        called on line 34 of file '/Users/ian/.config/fish/config.fish',

in . (source) call of file '/Users/ian/.config/fish/config.fish',
        called on standard input,

fish: Illegal command name '[[ ":$PATH:" != *":$TMUXIFIER/bin:"* ]]'
/Users/ian/.tmuxifier/init.sh (line 9): if [[ ":$PATH:" != *":$TMUXIFIER/bin:"* ]]; then
                                           ^
in . (source) call of file '/Users/ian/.tmuxifier/init.sh',
        called on line 1 of file '-',

in . (source) call of file '-',
        called on line 34 of file '/Users/ian/.config/fish/config.fish',

in . (source) call of file '/Users/ian/.config/fish/config.fish',
        called on standard input,

fish: The '$' character begins a variable name. The character '(', which directly followed a '$', is not allowed as a part of a variable name, and variable names may not be zero characters long. To learn more about variable expansion in fish, type 'help expand-variable'.
/Users/ian/.tmuxifier/init.sh (line 15): if [ -n "$(command -v "tmuxifier")" ] && [ -z "$TMUXIFIER_NO_COMPLETE" ]; then
                                                 ^
in . (source) call of file '/Users/ian/.tmuxifier/init.sh',
        called on line 1 of file '-',

in . (source) call of file '-',
        called on line 34 of file '/Users/ian/.config/fish/config.fish',

in . (source) call of file '/Users/ian/.config/fish/config.fish',
        called on standard input,

fish: Expected a command name, got token of type 'Run job in background'. Did you mean 'COMMAND; and COMMAND'? See the help section for the 'and' builtin command by typing 'help and'.
/Users/ian/.tmuxifier/init.sh (line 15): if [ -n "$(command -v "tmuxifier")" ] && [ -z "$TMUXIFIER_NO_COMPLETE" ]; then
                                                                                ^
in . (source) call of file '/Users/ian/.tmuxifier/init.sh',
        called on line 1 of file '-',

in . (source) call of file '-',
        called on line 34 of file '/Users/ian/.config/fish/config.fish',

in . (source) call of file '/Users/ian/.config/fish/config.fish',
        called on standard input,

fish: Could not locate end of block. The 'end' command is missing, misspelled or a ';' is missing.
/Users/ian/.tmuxifier/init.sh (line 16):   if [ -n "$BASH_VERSION" ]; then
                                           ^
in . (source) call of file '/Users/ian/.tmuxifier/init.sh',
        called on line 1 of file '-',

in . (source) call of file '-',
        called on line 34 of file '/Users/ian/.config/fish/config.fish',

in . (source) call of file '/Users/ian/.config/fish/config.fish',
        called on standard input,


       if - if - conditionally execute a command


if - conditionally execute a command
   Synopsis
       if CONDITION; COMMANDS_TRUE...; [else if CONDITION2;
       COMMANDS_TRUE2...;] [else; COMMANDS_FALSE...;] end

   Description
       if will execute the command CONDITION. If the condition's exit status
       is 0, the commands COMMANDS_TRUE will execute. If the exit status is
       not 0 and else is given, COMMANDS_FALSE will be executed.

       In order to use the exit status of multiple commands as the condition
       of an if block, use begin; ...; end and the short circuit commands and
       and or.

       The exit status of the last foreground command to exit can always be
       accessed using the $status variable.

   Example
       if test -f foo.txt
               echo foo.txt exists
       else if test -f bar.txt
               echo bar.txt exists
       else
               echo foo.txt and bar.txt do not exist
       end

       will print foo.txt exists if the file foo.txt exists and is a regular
       file, otherwise it will print bar.txt exists if the file bar.txt exists
       and is a regular file, otherwise it will print foo.txt and bar.txt do
       not exist.

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

Fish shell integration is not working

When I'm doing the part of Setup with eval (tmuxifier init -) I get the following error:

fish: Unknown command “export”
- (line 1): begin; export TMUXIFIER="/home/wm/.tmuxifier"; source "$TMUXIFIER/init.sh"; ;end 
                   ^
in . (source) call of file “-”,
    called on line 21 of file “/home/wm/.config/fish/config.fish”,

in . (source) call of file “/home/wm/.config/fish/config.fish”,
    called on standard input,

fish: Unknown command “source”
- (line 1): begin; export TMUXIFIER="/home/wm/.tmuxifier"; source "$TMUXIFIER/init.sh"; ;end 
                                                           ^
in . (source) call of file “-”,
    called on line 21 of file “/home/wm/.config/fish/config.fish”,

in . (source) call of file “/home/wm/.config/fish/config.fish”,
    called on standard input,

Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish

It seems like the init.fish is not loaded. Do I have to put it in the ~/.config/fish folder? I'm a fish newbie so I can't really help you much with this issue.

`load-window` command does not honor session_root

I have a predefined tmuxifier session called 'derp' that includes 3 windows and would like to load a 4th on-demand:

# Filename: derp.session.sh
session_root "~/workspace/derp"

if initialize_session "derp"; then
  #1 pane:
  #  - ssh connection to remote server, then connect to screen running an IRC client
  load_window "irc"

  #2 panes:
  #  - vim
  #  - test runner (guard)
  load_window "ruby-editor" # 2 panes: vim, test runner

  # NOTE: commented-out to be run ad-hoc
  # 
  #load_window "rails-server" # 2 panes: 'rails s', 'tail -F log/development.log'

  new_window "misc"

  select_window 2
fi

# Finalize session creation and switch/attach to it.
finalize_and_go_to_session

If you notice, 'rails-server' is commented out since I'm not always working on rails projects. All 3 windows are loaded with the correct session root. When I run tmuxifier load-window rails-server from the 'misc' window, however, it loads it from my home directory.

I expected it to load the session_root directory instead of the home directory.

Not show cmd?

Hello, when run_cmd works, in there a way to not make the command appear in the terminal?

Word completion for layouts

I would be great of the load-session/load-window command can autocomplete the session/window in ls/lw.

Thanks.

Passing command line arguments

Is there any way to pass command line arguments through from invocation into a particular pane in the script? I would like to specify a server to ssh to using something like tmuxifier load-window debug servername and as part of the window creation pass the "servername" to ssh in a pane. Here is a test script I wrote -

new_window "debug"
split_h 30
split_v 50
run_cmd "htop"  2   # runs in active pane
run_cmd "sudo tail -f /var/log/messages" 3
run_cmd "echo vars :: $# :: $0 :: $1 :: $2 :: $3" 1
select_pane 1

Using the command above to invoke it I would expect "servername" to show up somewhere in the echo statement but I get nothing except the name of the window-

vars :: 1 :: /sysadmin/home/rdhender/.tmuxifier/libexec/tmuxifier-load-window :: debug :: ::  

I LOVE tmuxifier by the way, thank you for creating it!

Fussy match `load-session`

If we match the string with available sessions and only one match is found, we can just load the layout.

$ tmuxifier ls
projectA
projectB
wip@server

$ tmuxifier s B  # projectB is loaded

$ tmuxifier s wip  # wip@server is loaded

$ tmuxifier s project # error
"project" may mean one of the following:
projectA
projectB

Expand test suite

As of #46 there's a decent test framework/skeleton and some basic tests added, but more are needed.

Todo

Below is an overview of things in need of tests along with the current test status.

  • Basic test framework setup.
  • Main tmuxifier executable in bin folder.
  • Files in lib folder:
    • env.sh
    • layout-helpers.sh:
      • tmux()
      • new_window()
      • split_v()
      • split_h()
      • split_vl()
      • split_hl()
      • clock()
      • select_window()
      • select_pane()
      • send_keys()
      • run_cmd()
      • session_root()
      • window_root()
      • load_window()
      • load_session()
      • initialize_session()
      • finalize_and_go_to_session()
      • __expand_path()
      • __get_first_window_index()
      • __get_current_window_index()
      • __go_to_session()
      • __go_to_window_or_session_path()
    • runtime.sh
    • util.sh
  • Files in libexec folder:
    • tmuxifier-alias
    • tmuxifier-commands
    • tmuxifier-completions
    • tmuxifier-current-session
    • tmuxifier-edit-session
    • tmuxifier-edit-window
    • tmuxifier-help
    • tmuxifier-init
    • tmuxifier-list
    • tmuxifier-list-sessions
    • tmuxifier-list-windows
    • tmuxifier-load-session
    • tmuxifier-load-window
    • tmuxifier-new-session
    • tmuxifier-new-window
    • tmuxifier-resolve-command-path
    • tmuxifier-tmux
    • tmuxifier-tmux-version
    • tmuxifier-version

Tests - Unit and Integration

Tmuxifier has gotten to the level of complexity where it's become quite painful for me to change/add features while attempting to ensure I haven't broken anything. For that reason I'll be focussing on getting some basic and decent tests in place.

I'll be using assert.sh together with my own stub.sh library. The combination has been working quite well for me on another as of yet unreleased project.

Split number is from top or bottom?

I have split_v 80 and the split is near the top (small top pane, large bottom pane).
Changing it to 10 makes it near the bottom (large top pane, small bottom pane).
What gives?

`load-session` does not honor session_root

Similar to #61. When opening a new tmux session from another tmux session (both using tmuxifier), the first session_root is honored in the second session. For example:

# Filename: fizz.session.sh
session_root "~/workspace/fizz"

if initialize_session "fizz"; then
  #1 pane:
  #  - ssh connection to remote server, then connect to screen running an IRC client
  load_window "irc"
fi

# Finalize session creation and switch/attach to it.
finalize_and_go_to_session
# Filename: buzz.session.sh
session_root "~/workspace/buzz"

if initialize_session "buzz"; then
  #1 pane:
  #  - something to open vim with
  new_window "editor"
fi

# Finalize session creation and switch/attach to it.
finalize_and_go_to_session

When running tmuxifier s fizz, it loads the predefined fizz session just fine with the default path being ~/workspace/fizz for all new windows. I open a new window within tmux and run tmuxifier s buzz and it opens the predefined buzz session with the path remaining as ~/workspace/fizz. All subsequent windows in that session have paths of ~/workspace/buzz, however.

If spawning the buzz session is run outside of the fizz session, this problem does not occur. It does, though, show there is a bug with the idempotence of tmuxifier session generation.

Issue with split_h

When using the split_h there is a issue where it never splits the screen horizontally.

I found the problem, just not sure a way to fix it without spending a bit more time going through the code.

The function split_h and split_hl in /lib/layout-helpers.sh uses the switch -h

The issue here is, that /libexec/tmuxifier-tmux sends that -h to the calling-help function and the function thinks that the help switch is being called.

So the tmux never splits the screen, but tmuxifier just outputs, information here,

echo "usage: tmuxifier tmux [...]

My thought for a fix (but not sure if it could make other issues) is at here

if [[ " $@ " != *" --help "* ]] && [[ " $@ " != *" -h "* ]]; then
Have the if statement check to make sure "split-window or splitw" isn't currently included in the call. I was hoping tmux man page had a switch like --horizontal to easily fix this.

Thank you.

Update: I just did a quick fix here, of changing the -h to -H for help switch, but not sure if that'll make other issues. But horizontally splitting is now working.

Name of windows will be overwritten

I currently have created a window definition that looks like this

layouts/team_dashboard.window:

window_root "~/code/other/team_dashboard"
new_window "team_dashboard"
run_cmd "bundle exec rails s --port 3001" 0
select_pane 0

It all works fine but when I load this defintion (either tmuxifier w team_dashboard or in a session via load_window) the name of the window gets replaced with the last command (in this case bundle..)

Am I doing something wrong?

Requires 1.6 or greater

I was running tmux 1.5 and kept getting an error "list-panes: unknown option -F". I upgraded to 1.9a and this error went away. The -F option appears to have been added in tmux 1.6. Could tmuxifier notify me if my tmux is out of date?

Cannot load a session layout

I'm trying tmuxinator for the first time but I can't load a session layout, these are the steps to reproduce:

# Create new layout called "test"
tmuxifier new-session test

# Edit the session file as follow:
echo "1: $(tmux ls)"
initialize_session "test"; echo "2: $(tmux ls)"
finalize_and_go_to_session; echo "3: $(tmux ls)"

# Try to load the session
tmuxifier load-session test

# Output
1: Default: 1 windows (created Tue Feb 21 21:37:33 2023) (attached)
2: Default: 1 windows (created Tue Feb 21 21:37:33 2023) (attached)
test: 1 windows (created Tue Feb 21 21:50:03 2023)
can't find session: test
  1. My current Default session is the only one
  2. After calling initialize_session "test", the test session was created
  3. Somehow finalize_and_go_to_session seems to fail and I always get the same error: can't find session: test

tmux is left in the initial sate (e.g. only my Default session exists after the scripts fails)

Add iTerm2 support

I would like to be able to leverage on the iTerm2 terminal (OS X) tmux integration.

I am able to successfully use tmuxifier by itself. However, I can't figure out how to use it jointly with iTerm2. I have the following configuration by now:

# ~/.zshenv
export PATH="$HOME/.tmux/bundle/tmuxifier/bin:$PATH"
# ~/.zlogin
export TMUXIFIER_LAYOUT_PATH="$HOME/.tmux/layouts"
if [ "$TERM_PROGRAM" = 'iTerm.app' ] ; then
  export TMUXIFIER_TMUX_OPTS='-CC'
fi
eval "$(tmuxifier init -)"
# ~/.tmux.conf
setw -g aggressive-resize off

This results is an infinite loop when I execute tmuxifier load-session "$session_name". Do you guys have any lead?

Completion is failing if cursor placed before text

Given the following command: muxifier default, place your cursor before default and press TAB.

You will have the following result:

❯ tmuxifier usage: tmuxifier completion <command>

Print a list of available completions for specified command.
  default

I'm running under zsh.

saving session

Is there a way to save the current state of a session?

Tmuxifier creates server as x86_64 even though tmux on its own creates server as arm64

I reinstalled tmux and homebrew this morning on my M1 Macbook Pro to ensure they are using the arm64 architecture.

In my ZSH shell (outside tmux) I get this output for uname:

$ uname -m
arm64

Checking the tmux binary I get this output:

$ file $(which tmux)
/opt/homebrew/bin//tmux: Mach-O 64-bit executable arm64

If I run tmux (when no server exists) and check uname again:

$ uname -m
arm64

If I kill the tmux server and start a new tmux server by running a tmuxifier command, the session I land in will be x86_64:

$ uname -m
x86_64

However, if I kill the tmux server, start a fresh one with the tmux command, THEN use tmuxifier to create a session, that session will be in an arm64 context.

So it appears that starting a tmux server by using a tmuxifier command will create an x86_64 server, even though the tmux command knows to use arm64.

This causes a bunch of compatibility errors in treesitter in neovim.

load_session tries to pick up file in current dir

I have a session called "awesome", and when I try to run tmuxifier s awesome in a directory where a file called awesome exists, the following error happens:

layout-helpers.sh: line 206: source: /usr/bin/awesome: cannot execute binary file

This is caused by bash's source picking up the executable awesome, not the file from the current directory. For this source ./awesome would be required.

Anyway, the file awesome in the current dir is not a tmuxifier session, but a Vim session (IIRC).

Is it possible to make a session inherit the same environment variable?

Right now, I'm doing something like:

  new_window "server"
  run_cmd    "export NANOC_ENV=development"
  run_cmd    "blablala"

  new_window "main"
  run_cmd    "export NANOC_ENV=development"
  run_cmd    "asfasf"

Afaik, there's no easy way to make tmux inherit environment variables from the previous process, but I was wondering if this could be possible with tmuxifier.

Tmuxifier not waiting for session to be ready

I'm using zsh, which is apparently slow enough to cause the following bug.

image

All the run_cmd are run before the shell is ready and this nothing is really executed, I'm not sure what the issue could be or how to force tmuxifier to check for the session but I'm open to suggestions.

Error unknown option: default-path

Hio Jim,

thanks for this awesome plugin, I really enjoy and appreciate what you did because it is doing exactly the things which I missed by using tmuxinator.

Here is the reason for the error tmuxinator/tmuxinator#170.

I have the following session file:

if initialize_session "testt"; then
  load_window "padrino-book"
  load_window "job-vacancy"

  select_window 1
fi

finalize_and_go_to_session

and here is the contents of the two window layouts:

padrino-book

window_root "$HOME/Dropbox/padrino/manuscript"
new_window "section"
run_cmd "vim 02-04-user-profile.md"     # runs in active pane

window_root "$HOME/Dropbox/notes"
new_window "notes"
run_cmd "vim padrino.txt"

window_root "$HOME/Dropbox/notes"
new_window "todo"
run_cmd "vim padrino-todo.txt"

new_window "irc"
run_cmd "irssi"

job-vacancy:

window_root "~/git-repositories/job-vacancy"
new_window "job-vacancy"

run_cmd "vim"

split_v 20
run_cmd "bundle exec padrino s"
split_h 80
run_cmd "bundle exec rspec spec"

select_pane 1

Even when I turn of the window_root settings in each of my window layouts, I'm getting this error message. The strange thing is, that my window setup described above is working fine.

Maybe you can add some tmux 1.8 and 1.90 deprecation warning in your script so that no other users of your plugin get the impression that something is broken.

Best regards from Berlin.

Support for multiple layout directories

Hi, Is it possible to set multiple TMUXIFIER_LAYOUT_PATH somehow?

I would like the ability to have my own layouts, and also another shared default layouts folder in some shared mounted location.

Thanks for the great tool :)

Issue loading a window layout when session's `default-path` is set

If you're in a Tmux session which has it's default-path setting set, loading up a window layout which has a root path set via tmuxifier load-window will cause it to use the session's default-path instead.

I have a fix in mind to check for and temporarily store the sessions default-path value, set the option to the window root, create the window and panes, and reset the session default-path to it's original value. It's a little bit messy, and it will require window layouts to call a finalize function like session layouts do.

EDITOR not set

rrix@hobbes:verse ()
[master] ⚡$ tmuxifier new-session 'verse'
Layout file has been created, but '$EDITOR' is not set. Please 
manually open the layout for editing:
/home/rrix/.tmuxifier/layouts/verse.session.sh
rrix@hobbes:verse ()
[master] ⚡$ echo $EDITOR
/usr/bin/vim

Not going to stop me from using this, of course, just think this is odd, of course.

finalize_and_go_to_session can kill the wrong window

The default window that gets created on startup is not always numbered 99.

I use this option in my .tmux.conf:

set -g base-index 1

The default window then has number 0.

Ideally tmuxifier knows about this setting and kills either 0 or 99. Not sure how to go about this, though. As far as I know, there is no easy tmux command to extract this information. One way would be to do

tmux list-windows

Before all the session dependent windows are created and find out the number that way. But that feels a bit clumsy.

tmuxifier inside existing tmux session causes errors

A workflow I'm trying to achieve would allow me to spin up tmux sessions at will. However it seems as though if I'm currently inside a tmux session I get the following errors:

~ tmuxifier s example-session
can't find window example-window
couldn't set 'allow-rename'~

Any idea?

How to run commands without starting shell

Is there a way to send commands to tmux without having to start the shell and sending the command there?

In my old script (used before finding tmuxifier) I have:

tmux new-window -d -n "host" "ssh host"

which makes tmux name the window after the remote host and execute ssh directly, without first executing my login shell.

How do I achieve the same result from a tmuxifier config?

Using multiple nested `" "` in `run_cmd`

I want to run these kind of commands with from layout hi.window.sh
vim -c "echo 'Hi, how are you?'" ~/tmp/a.md

But I cannot from due to the extra " " needed for run_cmd "vim -c "echo 'Hi, how are you?'" ~/tmp/a.md "

Is there any workaround to do this? any alternative to run_cmd without the "" . Or any other symbol with same meaning that " " or ' '?

Thanks

Install on fish gives Warning

From the readme :

$ set -gx PATH "~/.tmuxifier/bin" $PATH
set: Warning: path component ~/.tmuxifier/bin may not be valid in PATH.
set: No such file or directory

$ fish -v
fish, version 2.1.0

It doesn't seem to be a problem, but I thought I'd raise it anyway.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.