Crates.io | pwds |
lib.rs | pwds |
version | 0.2.0 |
source | src |
created_at | 2016-07-27 19:13:29.053411 |
updated_at | 2016-10-31 11:27:22.66559 |
description | print the path of the current working directory, shortly |
homepage | https://github.com/rahiel/pwds |
repository | |
max_upload_size | |
id | 5800 |
size | 16,435 |
Print the path of the current working directory, shortly.
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
".". So /home/rahiel/.config/autostart
becomes ~/.c/autostart
.
Install pwds with cargo:
cargo install pwds
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:
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
replace \w
with $(pwds)
:
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]$(pwds)\[\033[00m\]\$ '
and enjoy a smaller prompt!
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:
export PWDS_LENGTH=10
The current (most right) directory is never shortened.
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.
pwds
.