Created
January 23, 2014 17:07
-
-
Save jamesdabbs/8582575 to your computer and use it in GitHub Desktop.
Tmux wrapper w/ zsh autocomplete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## In `.zshrc` | |
# The autocomplete function should set `reply` to an array of possibilities | |
function tmux_sessions() { reply=( $(ta --available) ) } | |
compctl -K tmux_sessions ta | |
## In `/path/to/ta` - which should be executable and on your path | |
#!/usr/bin/env ruby | |
session = ARGV.first | |
if session == "--available" | |
puts `tmux list-sessions`.lines.map { |l| l.split(":").first }.join " " | |
exit | |
end | |
opts = session.nil? ? "" : "-t #{session}" | |
cmd = ENV['TMUX'] ? "switch" : "attach" | |
system "tmux #{cmd} #{opts}".strip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment