Skip to content

Instantly share code, notes, and snippets.

@shaoyanmin
shaoyanmin / jump_or_exec.rb
Last active August 29, 2015 14:03
jump or execute a command - quick switch between apps
#! /home/ian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
app, cmd = ARGV
`wmctrl -l`.split("\n").each do |l|
if l =~ /#{app}/
pid = l.split.first
exec "wmctrl -i -a #{pid}"
end
end
exec "#{cmd}"