polylith icon indicating copy to clipboard operation
polylith copied to clipboard

Switch workspace via shortcuts

Open tengstrand opened this issue 1 year ago • 0 comments

Add support for switching workspace via shortcuts that are specified in the :ws-shortcuts key in the user config file ~/.config/polylith/config.edn (the value of :root-dir is added to the paths), e.g.:

{...
 :ws-shortcuts {:root-dir "/Users/joakimtengstrand/source/polylith"
                :paths [{:dir "examples/doc-example"}
                        {:dir "examples/multiple-workspaces2/backend"}
                        {:dir "../clojure-polylith-realworld-example-app" :name "realworld"}
                        {:file "../sandbox/another-ws.edn"}]
}

Now we can switch workspace with ddir:NAME or ffile:NAME where NAME is the name of the directory/file, or :name if given, e.g.:

polylith$ switch-ws ddir:
backend       (examples/multiple-workspaces2/backend)
doc-example                    (examples/doc-example)
realworld (../clojure-polylith-realworld-example-app)

If we for example select realworld then the tool will perform a switch-ws dir:../clojure-polylith-realworld-example-app for us:

polylith$ switch-ws ddir:realworld
dir:clojure-polylith-realworld-example-app$

We can always switch back to the root workspace with:

dir:clojure-polylith-realworld-example-app$ switch-ws
polylith$

The ffile parameter works the same, and this statement will perform a switch-ws file:../sandbox/another-ws.edn :

polylith$ switch-ws ffile:another-ws
file:another-ws$

tengstrand avatar Feb 27 '24 06:02 tengstrand