pax_global_header 0000666 0000000 0000000 00000000064 13007003241 0014500 g ustar 00root root 0000000 0000000 52 comment=a2a7df835bb7521584a238dc945abd12791f5273
bd-1.02/ 0000775 0000000 0000000 00000000000 13007003241 0012007 5 ustar 00root root 0000000 0000000 bd-1.02/LICENSE 0000664 0000000 0000000 00000002102 13007003241 0013007 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.02/README.md 0000664 0000000 0000000 00000005360 13007003241 0013272 0 ustar 00root root 0000000 0000000 # bd
#### Description
Quickly go back to a specific parent directory in bash instead of typing "cd ../../.." redundantly.
---
**Installation**
```shell
wget --no-check-certificate -O /usr/bin/bd https://raw.github.com/vigneshwaranr/bd/master/bd
chmod +rx /usr/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.
bd-1.02/bash_completion.d/ 0000775 0000000 0000000 00000000000 13007003241 0015377 5 ustar 00root root 0000000 0000000 bd-1.02/bash_completion.d/bd 0000664 0000000 0000000 00000000637 13007003241 0015715 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=$( pwd | sed 's|/|\n|g' )
COMPREPLY=( $(compgen -W "$completions" -- $cur) )
}
complete -F _bd bd
bd-1.02/bd 0000775 0000000 0000000 00000001766 13007003241 0012334 0 ustar 00root root 0000000 0000000 #! /bin/bash
usage_error () {
cat << EOF
------------------------------------------------------------------
Name: bd
Version: 1.02
------------------------------------------------------------------
Description: Go back to a specified directory up in the hierarchy.
------------------------------------------------------------------
How to use:
Please refer https://github.com/vigneshwaranr/bd
EOF
}
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')
;;
*)
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.02/run-tests.sh 0000775 0000000 0000000 00000004235 13007003241 0014316 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.02/screenshot/ 0000775 0000000 0000000 00000000000 13007003241 0014164 5 ustar 00root root 0000000 0000000 bd-1.02/screenshot/bd.png 0000664 0000000 0000000 00000435327 13007003241 0015275 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