GithubHelp home page GithubHelp logo

xcwd's Introduction

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`"

i3 Configuration

You can add a key binding like this one:

bindsym $mod+Shift+Return exec xcwd | xargs urxvt -cd

xcwd's People

Contributors

schischi avatar syl20bnr avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.