Created
April 9, 2014 17:28
-
-
Save tpikonen/10294723 to your computer and use it in GitHub Desktop.
URxvt perl module to allow opening of a new terminal window with a key combination
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Cwd; | |
# Opening a new window. | |
# Fixed version of script from | |
# http://lists.schmorp.de/pipermail/rxvt-unicode/2012q3/001609.html | |
# by José Romildo Malaquias <malaquias at gmail.com> | |
# References: man 3 urxvtperl | |
# Debugging: urxvt --perl-lib ${HOME}/.urxvt -pe new-window | |
# Example config: URxvt.keysym.Control-Shift-N: perl:new-window | |
sub new_window | |
{ | |
my ($self) = @_; | |
my $ccwd = readlink("/proc/".$self->{child_pid}."/cwd"); | |
new urxvt::term $self->env, $urxvt::RXVTNAME, -cd => $ccwd; | |
} | |
sub on_child_start { | |
my ($self,$pid) = @_; | |
$self->{child_pid} = $pid; # keep for later determining our shells | |
# CWD for relative path names | |
() | |
} | |
sub on_user_command | |
{ | |
my ($self, $cmd) = @_; | |
if ($cmd eq "new-window") { | |
new_window($self); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This extension is great and should be part of the standard urxvt extensions. Using a tiling window manager, I very often need new terminals in the current working directory.