Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to descend into subdir of parent dir #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

udiboy1209
Copy link

Instead of doing cd ../../../parent/subdir or cd $(bd parent)/subdir
you can do bd parent/subdir to get the same result.
The argument provided is split into a search string and a descend path.
The search string is used instead of $2 (or $1) in the main code, so
-s and -si work the same way as before,
and the descend path is appended to $NEWPWD if match is found.

Note: the argument is split at the first / only so its possible
to do something like bd parent/subdir/subdir2/subdir3

Example:

You are in dir /home/user/project/src/org/main/site/utils/file/reader/whatever , and lets say src has another directory com.
you can easily go to com using bd src/com. No need to use bd's output to run another cd. I mean that's the whole purpose of bd right?

You can also do bd sr/com or bd SRc/com if your alias uses -s or -si respectively.

Instead of doing 'cd ../../../parent/subdir' or 'cd `bd parent`/subdir'
you can do '. bd parent/subdir' to get the same result.
The argument provided is split into a search string and a descend path.
The search string is used instead of $2 (or $1) in the main code, so
-s and -si work the same way as before,
and the descend path is appended to $NEWPWD if match is found.

Note: the argument is split at the first '/' only so its possible
to do something like '. bd parent/subdir/subdir2/subdir3'
@udiboy1209 udiboy1209 mentioned this pull request May 13, 2014
@udiboy1209
Copy link
Author

I need help making bash_completion work with the new feature.

Basic completion works fine, but the subdir path completion is more of a hack.

Some suggestions would be great!

The basic search string is completed like before
Path completion is supported for the descend path
Special characters are correctly escaped
Loads of room for improvement in the completion function
using the `filenames` option.
Better than escaping them using a substituion regex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant