Extension to open new terminal with same working directory

Michal Nazarewicz mina86 at tlen.pl
Thu Sep 16 23:11:46 CEST 2010


David House <dmhouse at gmail.com> writes:

> On 15 September 2010 21:06, Edward Z. Yang <ezyang at mit.edu> wrote:
>> Excerpts from David House's message of Wed Sep 15 04:45:31 -0400 2010:
>>> I'd like M-S-RET to open a new terminal with the same working
>>> directory as the old buffer. Has anyone written an extension to do
>>> this, or is this possible in vanilla urxvt?
>>
>> I use the following shell script to do this:
>>
>> #!/bin/bash
>> NUM=$1
>> if [[ -z $1 ]]; then NUM="1"; fi
>> for i in $(seq 1 $1)
>> do
>>    nohup rxvt-unicode 2>/dev/null > /dev/null &
>> done

Personally, I'd write that as:

#!/bin/sh
for i in $(seq ${1:-1}; do
	nohup >/dev/null 2>&1 $
done

> That seems to me like it will just open a number of terminals equal to
> the script's first argument. That's not what I want -- I wanted to
> open a single new terminal with the same working directory as the
> existing one.

All the terminals will be opened with a working directory equal to the
terminal this script is invoked from.  With no arguments it will open
one terminal.

"Working directory of existing terminal" (or rather shell in the
terminal) is not really something trivial to get.  Hopefully, the above
will be enough for you.

-- 
Best regards,                                         _     _
 .o. | Liege of Serenly Enlightened Majesty of      o' \,=./ `o
 ..o | Computer Science,  Michal "mina86" Nazarewicz   (o o)
 ooo +--<mina86-tlen.pl>--<jid:mina86-jabber.org>--ooO--(_)--Ooo--




More information about the rxvt-unicode mailing list