{"id":19401483,"url":"https://github.com/ayosec/spwd","last_synced_at":"2025-04-24T07:30:43.777Z","repository":{"id":4266579,"uuid":"5393967","full_name":"ayosec/spwd","owner":"ayosec","description":"ShorterPWD: show the current path, trimming the parents to fit a certain width","archived":false,"fork":false,"pushed_at":"2020-05-24T21:37:44.000Z","size":55,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T01:04:26.029Z","etag":null,"topics":["prompt","shell-prompt"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"grant/react-talk","license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayosec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-13T02:22:05.000Z","updated_at":"2022-12-26T09:58:02.000Z","dependencies_parsed_at":"2022-09-17T04:10:12.368Z","dependency_job_id":null,"html_url":"https://github.com/ayosec/spwd","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayosec%2Fspwd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayosec%2Fspwd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayosec%2Fspwd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayosec%2Fspwd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayosec","download_url":"https://codeload.github.com/ayosec/spwd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250582806,"owners_count":21453917,"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":["prompt","shell-prompt"],"created_at":"2024-11-10T11:18:41.704Z","updated_at":"2025-04-24T07:30:43.498Z","avatar_url":"https://github.com/ayosec.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ShorterPWD\n\nShorterPWD is a tool to show the current path, trimming the parents to fit a certain width. It is intended to be used in the prompt (`PS1` or equivalent).\n\n## Example\n\nFirst, we start in a *very* long path:\n\n```console\n$ mkdir -p /tmp/lorem/ipsum/dolor/sit/amet/consectetur/adipisicing/elit/sed/do/eiusmod\n\n$ cd /tmp/lorem/ipsum/dolor/sit/amet/consectetur/adipisicing/\n```\n\nThen, with `spwd -m 40` we print the path trimmed to 40 characters:\n\n```console\n$ spwd -m 40\n/t/l/i/d/s/amet/consectetur/adipisicing\n\n$ cd elit/sed/do/eiusmod\n\n$ spwd -m 40\n/t/l/i/d/s/a/c/a/elit/sed/do/eiusmod\n\n$ spwd -m 20\n/t/l/i/d/s/a/c/a/e/s/d/eiusmod\n```\n\nThe parents are trimmed to their first character until the length of the path is smaller than the value in the `-m` option. The last part is never trimmed.\n\nYou can always trim all parents with `spwd -m 0`.\n\n## Aliases\n\nspwd can replace a path prefix with an alias.\n\nThe aliases are defined in a file with the following format:\n\n```\nalias1 = path1\n\n# Comment\nalias2 = path2\n```\n\nTo use them, add the `-a path` option to the `spwd` command.\n\nTheses aliases are never trimmed.\n\n### Example\n\nFirst, create a file `~/.config/spwd/aliases`:\n\n```\n[My Projects] = /here/are/my/projects\n[Work] = /home/user/content/work\n```\n\nThen, update the `PS1` variable to include the `-a` option:\n\n```bash\nPS1='\\u@\\h $(spwd -m 40 -a ~/.config/spwd/aliases)\\$ '\n```\n\nNow, we can see our alias in the prompt instead of the full path.\n\n```\n~ $ cd /here/are/my/projects/something\n\n[My Projects]/something $\n```\n\n## Installation\n\nUse `make install` to compile and install the tool.\n\n```\n$ git clone https://github.com/ayosec/spwd.git\n$ cd spwd\n$ make test\n$ sudo make install\n```\n\nBy default it is installed in `/usr/local/bin`. If you want a different destination use the `DEST` variable. For example, to install the tool in `/usr/bin`, type:\n\n```bash\n$ sudo make DEST=/usr install\n```\n\n## Usage\n\nTo use spwd in your prompt, replace the sequence `\\w` with `$(spwd -m XX)` in your `PS1` variable.\n\nFor example, instead of:\n\n```bash\nPS1='\\u@\\h \\w\\$ '\n```\n\nUse:\n\n```bash\nPS1='\\u@\\h $(spwd -m 40)\\$ '\n```\n\n## Tests\n\nTo launch the tests type `make test` in the root directory.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayosec%2Fspwd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayosec%2Fspwd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayosec%2Fspwd/lists"}