Created
December 9, 2015 21:58
-
-
Save ahoward/97d0ddc47f7626b8d1e6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #! /usr/bin/env ruby | |
| # this program (on osx and probably others) will give you a 'named screen' | |
| # (ns) command that will create named screens that will also name Terminal.app | |
| # tabs, even on re-attach. save it in ~/bin/ns and use as in | |
| # | |
| # to create a named screen | |
| # | |
| # ns ~/src/foobar | |
| # | |
| # to detach use the standard | |
| # | |
| # Ctrl-A d | |
| # | |
| # to attache to a previously named screen use | |
| # | |
| # ns ~/src/foobar | |
| # | |
| # in both cases (creation and attaching) your terminal tab will get named | |
| # appropriately | |
| # | |
| # the default argument is '.' do | |
| # | |
| # cd ~/src/foobar | |
| # ns | |
| # | |
| # works to create a screen named 'foobar' too | |
| # | |
| system("#{ ScreenProgram } -wipe") | |
| exec(Screen) | |
| # | |
| BEGIN { | |
| require 'fileutils' | |
| require 'tmpdir' | |
| Home = File.expand_path('~') | |
| Name = File.basename(File.expand_path(ARGV.shift || '.')).gsub(%r/\W/,'_').squeeze('_').chomp('_') | |
| Fu = FileUtils | |
| Screens = File.join(Home, '.screens') | |
| ScreenProgram = `which screen`.strip | |
| Screen = File.join(Screens, Name) | |
| Current = ENV['Screen'] | |
| FileUtils.mkdir_p(Screens) | |
| script = <<-__.strip | |
| #! /usr/bin/env bash | |
| screen -d -R -S #{ Name.inspect } | |
| __ | |
| IO.binwrite(Screen, script) | |
| FileUtils.chmod(0777, Screen) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment