summaryrefslogtreecommitdiff
path: root/README.md
blob: aba7670579ab90d6e1247f703e57b3b576aa5a0d (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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.

Disclaimer
----------
This script *can't* retrieve the working directory of a "single instance
application" nor terminal multiplexer, e.g. :
  - tmux, screen
  - lilyterm
  - konsole
  - urxvt*c*
  - applications with tabs

The application works well with the following terminals :
  - urxvt
  - xterm
  - gnome terminal

How it works
------------
  - Retrieve the focused window
  - Read its attributes to get the PID. If `_NET_WM_PID` is set, xcwd just
    read the value. Otherwise it reads the `_NET_WM_CLASS` and compares it to
    the name of all the running processes
  - Search for the deepest child of the selected PID (to avoid getting the
    working directory of the terminal instead of the shell)
  - Print the current working directory

If one of those steps fail, xcwd print the content of the `HOME` variable.

Requirements
------------
  - Linux or FreeBSD
  - libX11-dev

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

You probably want to use it this way:
    ``urxvt -cd "`xcwd`" ``
    ``xterm -e "cd `xcwd` && /bin/zsh"``

i3 Configuration
----------------
bindsym $mod+Shift+Return exec ``urxvt -cd "`xcwd`" ``
bindsym $mod+Shift+Return exec ``xterm -e "cd `xcwd` && /bin/zsh"``