Bash cd alias: cdots

From FVue
(Redirected from Bash: Cdots)
Jump to: navigation, search

Introduction

Cdots is an alternative function for alias ..='cd ..'. Cdots provides aliases .. ... .... etc. with an additional tab completed argument for taking a U-turn, for example:

/usr/local/share$ ... sh<TAB><ENTER>
/usr/share$

Seven functions will be created; 2-8 dots which allow you to move 1-7 directories up, and additional directories down again with tab completion. In pseudo-code, cdots allows you to do this:

.. [dir] = cd ../[dir]
... [dir] = cd ../../[dir]
.... [dir] = cd ../../../[dir]
..... [dir] = cd ../../../../[dir]
...... [dir] = cd ../../../../../[dir]
....... [dir] = cd ../../../../../../[dir]
........ [dir] = cd ../../../../../../../[dir]

Download

Installation

For more information, see INSTALL

Copy cdots.sh to your home directory:

cp cdots.sh ~/

Include cdots.sh from within ~/.bashrc:

source cdots.sh

Also consider putting this in your ~/.inputrc so you only have to press tab once – instead of twice – for completion:

# .inputrc
set show-all-if-ambiguous on  # Produce list of all possible completions at single tab

Test

The download contains an additional test suite. The test suite requires dejagnu, tcl and expect to be installed.

To run the tests:

$> cd test; ./runAll
WARNING: No tool specified
Test Run By freddy on Mon Jun 11 21:54:54 2007
Native configuration is i686-pc-linux-gnu

                ===  tests ===

Schedule of variations:
    unix

Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
WARNING: Couldn't find tool config file for unix, using default.
Running ./all/all.exp ...

                ===  Summary ===

# of expected passes            308

Release notes

See RELEASE

Caveats

Make sure bash programmable completion is enabled

shopt progcomp > /dev/null || shopt -s progcomp

See also


Comments

blog comments powered by Disqus


Comments

blog comments powered by Disqus