Jump to content

Recommended Posts

Posted

Tmux Workflow for Alfred app
Alfred workflow to manage tmux sessions, integrated with iTerm2. It can list current sessions, connect to them, kill them or create a new one. The connect or create action actually opens iTerm2 and connects to the session. Additionally, in all the open actions (new session or connect to session) it can cd to the current Finder's or Path Finder's directory.
Please note: the workflow only handles tmux sessions. It doesn't handle windows, panes, or any other tmux command.

Dependencies

  • iTerm2 installed
  • tmux installed in /usr/local/bin/tmux; easily installed with homebrew doing brew install tmux

Usage
Write the tmux keyword in Alfred to trigger the workflow. 

tmux-main-menu.png
The initial menu options are:

  • An initial not actionable menu item indicating to keep writing after the keyword to search/filter or create a new session.
  • Option to connect to a default tmux session. It's a session named "default" that will always appear in the menu, and if it doesn't exists it will be automatically created.

You can start typing right away after the keyword for search or create a session, or optionally add a space after the keyword for readability; the space is ignored. You'll see the filtered results (bash/zsh included), and a last option to created a new tmux session with the entered name, if non existent.
tmux-create-session.png
tmux-search-sessions.png
If you want to kill a session, action it with ⌥ down. If failure, for example trying to kill the bash/zsh option, you'll hear a classic error sound.
If you want to open the current Finder's or Path Finder's folder, action the current or new session with ⌘down. This command is very fast for new tmux sessions but adds a delay of 1 second for existent tmux sessions, since I cannot find a way to wait for tmux session to load, except by waiting long enough. Still, opening current Finder's path in already existing sessions shouldn't be that common.

Installation
For OS X 10.9 Mavericks, Download the alfred-tmux.alfredworkflow and import to Alfred 2.
For Previous OS X Versions, Download the alfred-tmux.alfredworkflow and import to Alfred 2.

 

Source Code

Clone or Fork the Workflow: https://github.com/ramiroaraujo/alfred-tmux-workflow

Changelog

  • 2014-02-05 - Released
  • 2 months later...
  • 5 months later...
Posted

Very nice workflow :)

 

Perhaps one nice addition would be to add support for wrapper scripts like tmx (here's my version: https://github.com/WoLpH/dotfiles/blob/master/bin/tmx) which automatically launches a new tmux session and activates your environment.

 

Currently I'm just using it from the shell with this little zsh completion script to save me some typing:

#compdef tmx

local active_sessions all_sessions

_active_sessions() {
    if [ -n "$(tmux ls 2>/dev/null)" ]; then
        active_sessions=($(tmux ls | awk -F ':' '{print $1}' | tr '\n' ' '))
    fi
}

_all_sessions() {
    [ -d ~/workspace ] && all_sessions=($(ls -1 ~/workspace | sed -e 's/\.sparseimage.*//' | grep -v '\.' | grep -iE '[a-z0-9]*'))
}

_active_sessions
_wanted active_sessions expl 'Active sessions' compadd -a active_sessions

_all_sessions
_wanted all_sessions expl 'All sessions' compadd -a all_sessions

  • 7 years later...
Posted

Not sure that author will respond since 8 years passed but it's worth a shot :)

 

Could you please help me with the error? 

 

[23:33:56.323] ERROR: Tmux[Script Filter] Code 1: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- alfred (LoadError)
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from feedback.rb:5:in `<main>'

 

I'm not a ruby guy. Errors tells that cannot find the 'alfred' library but apparently it's part of Alfred package and it shouldn't be a problem.

 

Thanks in advance.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...