Skip to content

Instantly share code, notes, and snippets.

@tpikonen
Created April 9, 2014 17:28
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tpikonen/10294723 to your computer and use it in GitHub Desktop.
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
#!/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);
}
}
@schoettl
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment