summaryrefslogtreecommitdiff
path: root/README.md
blob: 289ae2792b6e08f23e3e90309ba2e112d61108d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
xcwd - X current working directory
==================================
xcwd is a simple tool which print the current working directory of the
currently focused window.

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.

How it works
------------
Since there is no proper options to get the pid of the currently focused
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`).

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
xcwd was unable to find the PID, it prints the content of the `HOME` variable.

Disclaimer
----------
This script can't retrieve the working directory of a shell in tmux, screen
or in an instance of urxvtc.

Requirements
------------
- Linux
- libX11-dev

Running xwcd
------------
Simply invoke the 'xcwd' command.

You probably want to use it this way:
    ``urxvt -cd `xcwd` ``