https://github.com/rahiel/pwds
Print the path of the current working directory, shortly.
https://github.com/rahiel/pwds
bash bash-prompt cli prompt pwd shell
Last synced: 3 months ago
JSON representation
Print the path of the current working directory, shortly.
- Host: GitHub
- URL: https://github.com/rahiel/pwds
- Owner: rahiel
- License: apache-2.0
- Created: 2016-07-27T17:55:02.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-26T10:09:59.000Z (over 7 years ago)
- Last Synced: 2025-06-20T05:48:45.397Z (4 months ago)
- Topics: bash, bash-prompt, cli, prompt, pwd, shell
- Language: Rust
- Homepage: https://crates.io/crates/pwds
- Size: 8.79 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# pwds
[](https://crates.io/crates/pwds)
[](https://travis-ci.org/rahiel/pwds)
[](https://github.com/rahiel/pwds/blob/master/LICENSE.txt)
[](https://crates.io/crates/pwds)**P**rint the path of the current **w**orking **d**irectory, **s**hortly.
The current working directory in your prompt can get uncomfortably large,
leaving little space to type your own commands. With pwds paths like
`/home/user/Code/rust/src/doc/nomicon` are displayed as `~/C/r/s/d/nomicon`.It shows the first two characters for (hidden) directories that start with a
dot. So `/home/rahiel/.config/autostart` becomes `~/.c/autostart`.# Installation
Install pwds with cargo:
``` shell
cargo install pwds
```
The directory `~/.cargo/bin` needs to be in your PATH for your shell to find the
`pwds` binary. Follow [this guide][path] if you need help.Then you need to customize your PS1 in your shell's initialization file, e.g.
`.bashrc`. Here is a standard prompt, the `\w` is an escape code for the current
working directory:
``` shell
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
```
replace `\w` with `$(pwds)`:
``` shell
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]$(pwds)\[\033[00m\]\$ '
```
and enjoy a smaller prompt![path]: https://www.rahielkasim.com/installing-programs-from-non-system-package-managers-without-sudo/
# Customization
By default, paths with more than 16 characters are shortened by replacing
directory names with their first character. This can be configured by setting
the `PWDS_LENGTH` environment variable:
``` shell
export PWDS_LENGTH=10
```
The current (most right) directory is never shortened.# References
I encountered the concept of `pwds` in [fish][] and more recently in [xonsh][],
two modern and user-friendly shells. I'd use xonsh but a few issues keep me from
switching. In the meantime I'm trying to improve the experience of the Bash
shell, with as one of the results this program.* [Bash prompts](https://sanctum.geek.nz/arabesque/bash-prompts/)
* [Alternative prompt directory shortening for Bash](https://sanctum.geek.nz/arabesque/prompt-directory-shortening/)
* [Python prototype of pwds][pwds.py][fish]: https://fishshell.com
[pwds.py]: https://gist.github.com/rahiel/cdfda857534bc9dd4456e404a996e38f
[xonsh]: http://xon.sh