pax_global_header 0000666 0000000 0000000 00000000064 14235754121 0014516 g ustar 00root root 0000000 0000000 52 comment=0a2fbfa8df39e04cdeecba21059d1c4d0adda712
bd-1.03/ 0000775 0000000 0000000 00000000000 14235754121 0012026 5 ustar 00root root 0000000 0000000 bd-1.03/LICENSE 0000664 0000000 0000000 00000002102 14235754121 0013026 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2013 Vigneshwaran Raveendran
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bd-1.03/README.md 0000664 0000000 0000000 00000006224 14235754121 0013311 0 ustar 00root root 0000000 0000000 # bd
#### Description
Quickly go back to a specific parent directory in bash instead of typing "cd ../../.." redundantly.
---
**Installation**
***For OS X/macOS***
Using [MacPorts](https://ports.macports.org/port/bd):
```bash
sudo port install bd
```
***For Debian/Ubuntu***
Packages available here:
https://tracker.debian.org/pkg/bd
https://launchpad.net/ubuntu/+source/bd
***For other OS***
```shell
wget --no-check-certificate -O /usr/local/bin/bd https://raw.github.com/vigneshwaranr/bd/master/bd
chmod +rx /usr/local/bin/bd
echo 'alias bd=". bd -si"' >> ~/.bashrc
source ~/.bashrc
# If you need autocomplete support, follow these two steps
wget -O /etc/bash_completion.d/bd https://raw.github.com/vigneshwaranr/bd/master/bash_completion.d/bd
source /etc/bash_completion.d/bd
```
To enable case-sensitive directory name matching, use `-s` instead of `-si` in the alias.
---
**How to use:**
If you are in this path `/home/user/project/src/org/main/site/utils/file/reader/whatever`
and you want to go to `site` directory quickly,
then just type:
`bd site`
In fact, You can simply type bd *\*
like `bd s` or `bd si`
If there are more than one directories with same name up in the hierarchy, bd will take you to the closest. (Not considering the immediate parent.)
---
**Other uses:**
Using bd within backticks (\`bd \\`
) prints out the path without changing the current directory.
You can take advantage of that by combining \`bd \\`
with other commands such as ls, ln, echo, zip, tar etc..
**Example:**
1. If you just want to list the contents of a parent directory,
without going there, then you can use:
ls \`bd p\`
in the given example, it will list the contents of
`/home/user/project/`
2. If you want to execute a file somewhere in a parent directory,
\`bd p\`/build.sh
will execute `/home/user/project/build.sh` while not changing the
current directory.
3. If you reside in `/home/user/project/src/org/main/site/utils/file/reader/whatever`
and want to change to `/home/user/project/test`, then try
cd \`bd p\`/test
---
**Screenshot:**

---
**Thanks:**
* [@jaysh](https://github.com/jaysh) - Autocomplete support
* [@rmhsilva](https://github.com/rmhsilva) - Case-Insensitive directory name matching
* [@janosgyerik](https://github.com/janosgyerik) - Test cases, BSD support
* [@phls](https://github.com/phls) - Packaging bd for Debian
---
**See also:**
* [Tarrasch/zsh-bd](https://github.com/Tarrasch/zsh-bd) - bd for zsh
* [0rax/fish-bd](https://github.com/0rax/fish-bd) - bd for [fish](http://fishshell.com/) shell
* [rvraghav93/win-bd](https://github.com/rvraghav93/win-bd) - bd for command prompt
* [peterwvj/eshell-up](https://github.com/peterwvj/eshell-up) - bd inspired command for Emacs' eshell
* [alebcay/awesome-shell](https://github.com/alebcay/awesome-shell) - A curated list of awesome command-line frameworks, toolkits, guides and gizmos
bd-1.03/bash_completion.d/ 0000775 0000000 0000000 00000000000 14235754121 0015416 5 ustar 00root root 0000000 0000000 bd-1.03/bash_completion.d/bd 0000664 0000000 0000000 00000000655 14235754121 0015734 0 ustar 00root root 0000000 0000000 #!/bin/bash
# Add autocomplete support for bd for bash.
_bd()
{
# Handle spaces in filenames by setting the delimeter to be a newline.
local IFS=$'\n'
# Current argument on the command line.
local cur=${COMP_WORDS[COMP_CWORD]}
# Available directories to autcomplete to.
local completions=$( dirname `pwd` | sed 's|/|\'$'\n|g' )
COMPREPLY=( $(compgen -W "$completions" -- $cur) )
}
complete -F _bd bd
bd-1.03/bd 0000775 0000000 0000000 00000003072 14235754121 0012343 0 ustar 00root root 0000000 0000000 #! /bin/bash
help_msg () {
printf "Usage: bd [OPTION]... [PATTERN]\n"
printf "Quickly go back to a specific parent directory in bash.\n\n"
printf "\e[1mOPTIONS\e[0m\n"
printf " %-28s %s\n" "-s" "PATTERN can match part of directory name"
printf " %-28s %s\n" "-si" "PATTERN is Case Insensitve and can be partial"
printf " %-28s %s\n" "-?, --help" "Display this message"
printf "\n\e[1mALTERNATE USAGE EXAMPLES\e[0m\n"
printf " %-28s %s\n" "\`bd -si som\`/script.sh" "Execute \"script.sh\" in matching path"
return 0
}
usage_error () {
cat << EOF
------------------------------------------------------------------
Name: bd
Version: 1.03
------------------------------------------------------------------
Description: Go back to a specified directory up in the hierarchy.
------------------------------------------------------------------
How to use:
Please refer https://github.com/vigneshwaranr/bd
EOF
return 1
}
newpwd() {
oldpwd=$1
case "$2" in
-s)
pattern=$3
NEWPWD=$(echo $oldpwd | sed 's|\(.*/'$pattern'[^/]*/\).*|\1|')
;;
-si)
pattern=$3
NEWPWD=$(echo $oldpwd | perl -pe 's|(.*/'$pattern'[^/]*/).*|$1|i')
;;
-?|--help)
help_msg
;;
*)
pattern=$2
NEWPWD=$(echo $oldpwd | sed 's|\(.*/'$pattern'/\).*|\1|')
esac
}
if [ $# -eq 0 ]
then
usage_error
elif [ "${@: -1}" = -v ]
then
usage_error
else
oldpwd=$(pwd)
newpwd "$oldpwd" "$@"
if [ "$NEWPWD" = "$oldpwd" ]
then
echo "No such occurrence."
else
echo $NEWPWD
cd "$NEWPWD"
fi
unset NEWPWD
fi
bd-1.03/run-tests.sh 0000775 0000000 0000000 00000004235 14235754121 0014335 0 ustar 00root root 0000000 0000000 #!/bin/bash
# make sure we're in the project directory
cd $(dirname "$0")
# just to include the functions defined in ./bd
. ./bd /dev/null > /dev/null
red='\e[0;31m'
green='\e[0;32m'
nocolor='\e[0m'
success=0
failure=0
total=0
assertEquals() {
((total++))
expected=$1
actual=$2
if [[ $expected = $actual ]]; then
((success++))
else
((failure++))
{
echo Assertion failed on line $(caller 0)
echo " Expected: $expected"
echo " Actual : $actual"
echo
} >&2
fi
}
# should do nothing if run with no args
oldpwd=/usr/share/info
newpwd $oldpwd
assertEquals $oldpwd $NEWPWD
# should jump for exact match
newpwd /usr/share/info share
assertEquals /usr/share/ $NEWPWD
# should jump for closest exact match
newpwd /usr/share/info/share/bin share
assertEquals /usr/share/info/share/ $NEWPWD
# should do nothing for prefix match without -s
oldpwd=/usr/share/info
newpwd $oldpwd sh
assertEquals $oldpwd $NEWPWD
# should jump for prefix match with -s
newpwd /usr/share/info -s sh
assertEquals /usr/share/ $NEWPWD
# should jump for closest prefix match with -s
newpwd /usr/share/info/share/bin -s sh
assertEquals /usr/share/info/share/ $NEWPWD
# should do nothing for mismatched case prefix match without -si
oldpwd=/usr/share/info
newpwd $oldpwd -s Sh
assertEquals $oldpwd $NEWPWD
# should jump for mismatched case prefix match with -si
newpwd /usr/share/info -si Sh
assertEquals /usr/share/ $NEWPWD
# should jump for mismatched case prefix match with -si
newpwd /usr/sHAre/info -si Sh
assertEquals /usr/sHAre/ $NEWPWD
# should jump for closest mismatched case prefix match with -si
newpwd /usr/share/info/share/bin -si Sh
assertEquals /usr/share/info/share/ $NEWPWD
# handling spaces: should do nothing for prefix match without -s
newpwd '/home/user/my project/src' my
assertEquals '/home/user/my project/src' "$NEWPWD"
# handling spaces: should jump for exact match
newpwd '/home/user/my project/src' -s my
assertEquals '/home/user/my project/' "$NEWPWD"
echo
[[ $failure = 0 ]] && printf $green || printf $red
echo "Tests run: $total ($success success, $failure failed)"
printf $nocolor
echo
bd-1.03/screenshot/ 0000775 0000000 0000000 00000000000 14235754121 0014203 5 ustar 00root root 0000000 0000000 bd-1.03/screenshot/bd.png 0000664 0000000 0000000 00000435327 14235754121 0015314 0 ustar 00root root 0000000 0000000 PNG
IHDR 7 Ȅ sBIT|d tEXtSoftware gnome-screenshot> IDATxw[)ET5ňĖf[
K1Q16XҶ?w|?uggsʴ3g(ӧOlƶmAQBmy"B!BY@UUB㐟a
>d2?&2eʔΎ[!B!b+xH$/<9sx0|&M#S^^1!B!Bl'J/3` $ʫY &`YatvB!B!b1fϞM~~>͛bb1`g&B!BD"((O>7f8@B!B!ٳQ+++cC!B!;Hq