mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit 7294fe669e585a8eb77c8dece81466a484d97269
parent df0537737c08c1fabfc22a06c869f68593d95331
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Wed, 21 Dec 2016 11:34:00 +0100

urxvtpwd

Diffstat:
urxvtpwd | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/urxvtpwd b/urxvtpwd @@ -0,0 +1,26 @@ +#!/bin/bash + +# run ARGV, with -cd FOLDER if FOLDER can be extracted from title of current +# window (see zsh config for how the title gets put in the window) + +# inspired by +# https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/%3C/p%3E.html + +ID=$(xdpyinfo | grep focus | cut -d ',' -f1 | rev | cut -d ' ' -f1 | rev) +TITLE=$(xprop -id "$ID" | grep -m1 WM_NAME) +MYPWD=$(echo "$TITLE" | cut -d'$' -f1 | cut -d'"' -f2- | cut -d':' -f2-) +MYPWD2="${MYPWD/#\~/$HOME}" + +echo $MYPWD2 > ~/scratch/pwd + +# http://superuser.com/a/403369/77814 +quoted_args="$(printf " %q" "$@")" + +if [ -z "$MYPWD2" ] +then + $quoted_args +else + echo "$quoted_args -cd $MYPWD2" > ~/scratch/pwd + $quoted_args -cd "$MYPWD2" +fi +