I recently switched from a 2015 Macbook Pro to a 2016 Lenovo ThinkPad X1 Carbon. My setup consists of Arch Linux with the awesome tiling window manager i3. As a web developer I need to quickly switch between projects as part of my daily workflow. I’ve built a small script that allows me to select a project and open my editor along with a terminal in an i3 workspace.
See the GIF below for a demonstration. Awesome!
Let me show you how it works.
First, the script finds all existing git repositories. Then,
dmenu is given the list to allow the user to pick one. If the user did so, we get the name and number of the current workspace and invoke
i3-msg to set the layout, load a JSON-encoded description of the layout and rename the workspace. i3 will pre-populate the workspace with dummy containers. They are filled by simply executing the appropriate programs.
Saving a layout is done with the
i3-save-tree command. You can restore a layout with the
append_layout <path> command. Learn more about saving and restoring layouts in the i3 docs. Make sure to read the section about editing the output of
i3-save-tree carefully because you will need to edit the JSON file manually.
dmenu_git anywhere in your
~/bin). Next, add the following to your i3 config (
Reload the i3 config and press
Pro Tip 2 (for Arch Linux users): If you get the following error when running
i3-save-tree, install the optional