xcwd/README.md

54 lines
1.5 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-12-23 21:47:10 -05:00
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
2013-05-02 10:50:52 -04:00
How it works
------------
2013-12-23 21:47:10 -05:00
- 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
2013-04-24 15:16:36 -04:00
2013-12-23 21:47:10 -05:00
If one of those steps fail, xcwd print the content of the `HOME` variable.
2013-06-23 13:07:55 -04:00
2013-04-24 15:05:53 -04:00
Requirements
------------
2013-12-23 21:47:10 -05:00
- Linux or FreeBSD
- libX11-dev
2013-04-24 15:05:53 -04:00
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`" ``
2013-12-23 21:47:10 -05:00
``xterm -e "cd `xcwd` && /bin/zsh"``
2013-07-26 11:42:39 -04:00
i3 Configuration
----------------
2013-12-23 21:47:10 -05:00
bindsym $mod+Shift+Return exec ``urxvt -cd "`xcwd`" ``
bindsym $mod+Shift+Return exec ``xterm -e "cd `xcwd` && /bin/zsh"``