{"id":13707152,"url":"https://github.com/windler/ws","last_synced_at":"2025-04-12T15:08:14.787Z","repository":{"id":151075870,"uuid":"115289883","full_name":"windler/ws","owner":"windler","description":"cli app to list your workspaces, git branch info and custom information","archived":false,"fork":false,"pushed_at":"2018-08-27T17:02:17.000Z","size":78,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T15:08:07.753Z","etag":null,"topics":["cli","custom","git","go","golang","list","projects","workspace","workspaces"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/windler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-12-24T22:19:27.000Z","updated_at":"2020-11-28T18:14:24.000Z","dependencies_parsed_at":"2024-01-14T20:34:21.647Z","dependency_job_id":null,"html_url":"https://github.com/windler/ws","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windler%2Fws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windler%2Fws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windler%2Fws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/windler%2Fws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/windler","download_url":"https://codeload.github.com/windler/ws/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586234,"owners_count":21128997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","custom","git","go","golang","list","projects","workspace","workspaces"],"created_at":"2024-08-02T22:01:21.993Z","updated_at":"2025-04-12T15:08:14.765Z","avatar_url":"https://github.com/windler.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/windler/ws.svg?style=svg)](https://circleci.com/gh/windler/ws) [![Go Report Card](https://goreportcard.com/badge/github.com/windler/ws)](https://goreportcard.com/report/github.com/windler/ws) [![codebeat badge](https://codebeat.co/badges/a03086b0-b04d-432f-924e-314ae55fb3b6)](https://codebeat.co/projects/github-com-windler-ws-master)\n# ws - workspace hero\n`ws` is a command line tool that helps you handling your workspaces. Its purpose is to\n- **list** all of your workspaces\n- get **git information** about your workspaces, like **git status** and **current branch**\n- run **custom commands** like start an editor or run tests\n\n![ws preview](ws.gif)\n\n## Installation\n`go get github.com/windler/ws`\n\n## Usage\nFirst, you have to set your workspace directory in your config file. It is located at `~/.wshero`. Add a line similar to the following:\n```yaml\nwsdir: /home/windler/projects/\n```\n Then, you can run `ws -h` to show the help page or `ws ls` to get workspace information.\n```bash\nws ls\n                    DIR                   |   GIT STATUS   | BRANCH\n+-----------------------------------------+----------------+--------+\n  /home/windler/projects/gittest          | UNMODIFED      | master\n  /home/windler/projects/go               | Not a git repo | /\n\n```\n\n## Custom config path\nThe config file default to `~ /.wshero`. If you want to change the default file location you can set the `env WS_CFG`.\n\n## Custom commands\nYou can create your own command which can be executed on your workspaces. With custom commands you can e.g.:\n- start test environment\n- run vsc commands\n- run tests\n- start editor\n- ...\n\nTo define you own commands edit your config file (default `~/.wshero`). The following example shows commands to start/stop an test environment and just print the current workspace:\n\n```yaml\nwsdir: /home/windler/projects/\nparallelprocessing: 3\ntableformat: \"{{cmd \\\"pws\\\" .}}|{{gitStatus .}}|{{gitBranch .}}\"\ncustomcommands:\n- name: pws\n  description: \"print the current ws name\"\n  cmd: \"echo {{.WSRoot}}\"\n- name: code\n  description: \"edit ws in vscode\"\n  cmd: \"code {{.WSRoot}}\"\n- name: testenv_up\n  description: \"starts a dev environment in background\"\n  cmd: \"docker-compose -f {{.WSRoot}}/project/docker-compose.yml -p {{.WSRoot}} up -d\"\n- name: testenv_down\n  description: \"stops the dev environment\"\n  cmd: \"docker-compose -f {{.WSRoot}}/project/docker-compose.yml -p {{.WSRoot}} down\"\n```\n\nWhen you run a custom command it will be executed in the current workspace. If you want to run it in a specific workspace pass a pattern as the first argument. The first workspace that matches your pattern will be used. E.g. if you want to start your editor for the workspace `/home/windler/projects/gittest` using the `code` custom command type the following: \n```bash\nws code gittest\n``` \n\nCustom command are also visible within the help-page\n\n```bash\nws -h\n(...)\nCOMMANDS:\n     ls            List all workspaces with fancy information.\n     pws           print the current ws name\n     testenv_up    starts a dev environment in background\n     testenv_down  stops the dev environment\n     help, h       Shows a list of commands or help for one command\n(...)\n```\n\n### variables\nYou can use variables in your custom cammands using `go-template` syntax. The following variables are available:\n\n| Variable       | Description                                        |\n|----------------|----------------------------------------------------|\n| WSRoot         | The absolute path of the current workspace         |\n| Args           | Array of provided args to the custom command. Acces e.g. via `{{index .Args 1}}`         |\n\n### cd to workspace\nThe `ws` command cannot change the `/proc/\u003cPID\u003e/cwd` of the terminal. Therefore, it is not possible to create a command that changes the terminals directory to a workspace root. As a workaround you can create a `.bashrc` / `.zshrc` function that wraps the `ws` command and creates its own cd command. Assuming you have defined the above `pws` custom command, such a function could look like this:\n\n```bash\n w() {\n    case \"$1\" in\n        cd)\n            cd $(ws pws ${@:2})\n            return 0\n            ;;\n    esac\n\n    ws $@\n }\n``` \n\nCalling `w cd my_ws` will change the terminals directory into the workspace root of `my_ws`. All other commands or flags will be delegated to the `ws` command.  \n\n## Custom table layout\nYou can modify the table from the `ls` command by passing the flag `--table pattern` or permamently by setting `tableformat` in the config file. The columns are separated by the pipe (`|`). You have to use the `go-template` syntax. The template is feeded with the workspace dir. The following functions are available for the output:\n\n| Function            | Description                                                                                 |\n|---------------------|---------------------------------------------------------------------------------------------|\n| wsRoot (dir)        | Prints the directory and adds an arrow if your current working direcotry is withing the dir |\n| gitStatus (dir)     | Prints the git status of the dir                                                            |\n| gitBranch (dir)     | Prints the current git branch of the dir                                                    |\n| cmd (name, dir)     | Runs the custom command in the dir and prints the output                                    |\n\nE.g. to print the current branch and the output of a custom command \"pws\" the pattern is the following: \n```bash\n{{gitBranch .}}|{{cmd \"pws\" .}}\n```\n\n# TODO\n- [ ] Add more tests\n- [ ] Add option to describe args for custom commands in help output\n- [ ] Add option to run commands in parallel \n- [ ] Provide binaries (support brew and stuff)\n- [ ] Implement auto update\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindler%2Fws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwindler%2Fws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwindler%2Fws/lists"}