xcwd/README.md

39 lines
1.2 KiB
Markdown
Raw Normal View History

2013-04-24 15:05:53 -04:00
xcwd - X current working directory
==================================
xcwd is a simple tool which print the current working directory of the
currently focused window.
2013-05-02 10:50:52 -04:00
2013-04-24 15:05:53 -04:00
The main goal is to launch applications directly into the same directory
as the focused applications. This is especially useful if you want to open
a new terminal for debugging or compiling purpose.
2013-05-02 10:50:52 -04:00
How it works
------------
2013-04-24 15:16:36 -04:00
Since there is no proper options to get the pid of the currently focused
2013-05-02 10:50:52 -04:00
windows, xcwd first try to read the `_NET_WM_PID` property.
If it fails, it reads the `_NET_WM_CLASS` and compares it to the name of
all the running processes (it's kind of `pidof name`).
2013-04-24 15:16:36 -04:00
When xcwd has got the PID, it search the deepest child he has, thus avoiding
getting the working directory of the terminal emulator instead of the shell.
Finally it prints the content of `/proc/pid/cwd` on the standard output. If
2013-05-02 10:50:52 -04:00
xcwd was unable to find the PID, it prints the content of the `HOME` variable.
2013-04-24 15:16:36 -04:00
2013-06-23 13:07:55 -04:00
Disclaimer
----------
This script can't retrieve the working directory of a shell in tmux, screen
or in an instance of urxvtc.
2013-04-24 15:05:53 -04:00
Requirements
------------
2013-05-02 10:50:52 -04:00
- Linux
2013-04-24 15:05:53 -04:00
- libX11-dev
Running xwcd
------------
Simply invoke the 'xcwd' command.
2013-05-02 10:50:52 -04:00
2013-04-24 15:05:53 -04:00
You probably want to use it this way:
2013-07-01 17:03:08 -04:00
``urxvt -cd "`xcwd`" ``