Skip to content

AlanHasty/prwd

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NAME
     prwd - print reduced working directory

SYNOPSIS
     prwd [-aVh]

DESCRIPTION
     prwd prints the absolute pathname of the current working directory to the
     standard output. It is similar to pwd but has a configuration file
     (~/.prwdrc) allowing a number of ways to shorten your current path. The
     command-line options are as follows:

     -V      Show current version.

     -h      Show usage.

     -a      Outputs all the aliases starting with '$' as shell variable
             exports. The output from this command is meant to be used with
             eval in your .profile file, see section ALIAS VARIABLES for more
             detailed information.

REASONING
     Most shells read $PS1 differently and have a very rigid way to display
     the current working directory.  prwd allows you to have one way to handle
     the display of your working directory and use it across multiple shells.
     It also has awareness of a few version control system (git and mercurial)
     and will display the current branch when you enter a project under
     version control.

     The keywords available in the configuration are described in the sections
     below. Lines starting with '#' are ignored.

ALIASES
     Defines a short name for a lengthy path, e.g.:

           alias *prwd /home/tamentis/projects/prwd

     If you are in "/home/tamentis/projects/prwd/doc/html/", prwd would return
     "*prwd/doc/html". If you have spaces in your directories, you can wrap
     your 'alias' parameters with double quotes:

           alias winDocs "/mnt/Windows XP/My Documents/"

     You can define multiple values for a single alias, this allows you to
     share your configuration on different machines, but keep the same alias,
     for example:

           alias $tp /home/tamentis/truveris/projects
           alias $tp /Users/tamentis/truveris/projects

     Aliases can be nested one level deep if you have a complicated directory
     hierarchy.

           alias $tp /home/tamentis/truveris/projects
           alias $constants $tp/pytruveris/truveris/constants/

MAX LENGTH
     Defines the maximum length to return, the default filler string is "...",
     the default length is 32, a value of 0 will disable the feature all
     together.

           set maxlength 20

     This setting would turn "~/projects/prwd/doc/html" into a shorter string:
     "...cts/prwd/doc/html". You can define the filler string with the
     'filler' variable:

           set filler "-"

     Or if your font/terminal/shell supports UTF:

           set filler "???"

     If you want prwd to keep complete path elements instead of cutting as
     much as possible, you can use this setting:

           set cleancut on

NEWSGROUP STYLE
     This will shorten the path by only displaying the first letter of each
     path components, toggle it with:

           set newsgroup on

     This will turn the "/home/tamentis/projects/prwd/src/nowhere" path into
     "/h/t/p/s/nowhere". Note that the newsgroup style filter is applied
     before the path is trimmed with 'maxlength'.

MERCURIAL
     You can see the currently selected branch as a prefix to your path
     whenever you are in a mercurial repository, enable this feature with the
     following option:

           set mercurial on

     The resulting path will be "my-branch:project/folder".

GIT
     You can see the currently HEAD position as a prefix to your path when you
     are in a git repository, you can enable this feature with the following
     option:

           set git on

     The resulting path will be "my-branch:project/folder" if you are located
     on the HEAD of a branch, it will be "59cefd9...:project/folder" if you
     are anywhere else.

ALIAS VARIABLES
     Since you already define your aliases in your prwdrc file, you might want
     to use them in your shell without having to redefine them somewhere else.
     If you prefix your aliases with a '$' and add the following line to your
     .profile, you will be able to do exactlt that:

           eval `prwd -a`

     You can then use your aliases in your shell using the variable name, for
     example:

           cd $py3k

PS1 REPLACEMENT
     The following options are pulled from much higher context and have
     nothing to do with your current path. They have been added to prwd
     because they are simple to implement and make the handling of both
     hostname and uid indication more streamlined. This one will prefix
     everything with the short hostname:

           set hostname on

     The result will look like "myhostname:project/folder". Combined with the
     following:

           set uid_indicator on

     You will obtain something like "myhostname:project/folder$" which is as
     close as you could get to your typical default PS1 on your average shell.

SETUP
     This will depend on your shell, but the following will usually do (ksh
     and bash):

           export PS1='\h:`prwd`\$ '

     Note that the single quote matters since you want to keep the command
     within the variable as-is (unresolved). If you use both the hostname and
     uid_indicator options, you can simplify your PS1 even more:

           export PS1='`prwd` '

SEE ALSO
     pwd(1), csh(1), ksh(1), sh(1), getcwd(3)

AUTHORS
     prwd was written by Bertrand Janin <b@janin.com> and is distributed under
     an ISC license (BSD compatible, OSI compatible).

     A bunch of utility functions are borrowed from OpenBSD and OpenSSH, both
     under ISC and BSD licenses, with copyrights from the following authors:

      Copyright (c) 2004 Ted Unangst and Todd Miller
      Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
      Copyright (c) 2000 Markus Friedl.  All rights reserved.
      Copyright (c) 2005,2006 Damien Miller.  All rights reserved.

About

Prints the working directory with a few 'enhancements' from pwd: aliases, max length and filler characters, mercurial and git branches, newsgroup style.

Resources

License

Stars

Watchers

Forks

Packages

No packages published