vigneshwaranr / bd Goto Github PK
View Code? Open in Web Editor NEWQuickly go back to a parent directory in linux instead of typing "cd ../../.." repeatedly
License: MIT License
Quickly go back to a parent directory in linux instead of typing "cd ../../.." repeatedly
License: MIT License
bd folder name does only echo the target directory but does not actually switch to it.
I am using ubuntu 19.10 and fish 3.0.2, the same problem does exist in bash. Is there something to make it change the directory instead of just printing the target directory?
Hi,
This script is great and I'd like to see it included in the GNU tools ^^
Just a little suggestion, make the -s option activated by default to avoid the alias in .bashrc. And add a "-S" option for "strict search"
This is just a suggestion. You are free to reject it.
What is the effect of bd
(without any parameters)?
In most cases it does cd ..
, wich I like!
But consider this:
$ pwd
/home
$ bd
/home
$ pwd
/home
Expected: cd
to /
The convention is to have one. Also, as soon as one has an alias, bd -h
won't print the help.
For the man page, the default output of bd
would need to be reformatted to meet the conventions.
See https://github.com/clvv/fasd for an example of how to create a man page from a Markdown master using Pandoc.
It just echos out the present working directory. Tried it in bash shell works perfectly. sourced the config.fish file by inserting this line too alias bd=". bd -si"
throws this error
.: Error encountered while sourcing file “bd”: .: No such file or directory
Would be very helpful unfortunately I have no experience in writing them
Hey.
The current feature of bd
is to allow one to go back to any parent dir above the current working directory.
I'd propose another respectively additional mode:
bd
keeps a (configurable) array of last current working directoriesbash
, it could be easily added to the PROMPT_COMMAND
and from there read PWD
, respectively add it to some array (which should get some name, that hopefully nothing else uses (e.g. BASH_BD_PWD_RRDB
or something better ;-) ) .PWD
is to be added it's checked whether it's already in the array, if so, it's just moved to the end (similarly by unsetting the old one, "re-indexing" the array and then adding it newly (not doing this, if it was the last element)The interface could be as follows:
bd
would cd
to itbd
/
which cannot appear in the current arguments to it anywaye.g.:
/home/foo/test/bar$ bd<tab>
0: /usr
1: /home/foo/test
2: /proc/2343/fd
home foo test
$
So the last line is what we have currently.
The other lines are the previous current working dirs.
If one now enters e.g. bd /0
it would cd to /usr
and then the list would look like:
0: /home/foo/test
1: /proc/2343/fd
2: /home/foo/test/bar
(and 0: /usr
would be hidden in the array already)
Another config option could allow to hide out any dirs in the list, which are parents of the current dir, since these are already quickly reachable via the last line, e.g. above:
/home/foo/test/bar$ bd<tab>
0: /usr
2: /proc/2343/fd
home foo test
$
1: /home/foo/test
wouldn't be printed, because it's already reachable via the test
.
Of course it cannot be deleted from the array, because if one moves to another dir, it would be needed again.
And just bd
could be made a shortcut for going to the last one in the list, so consecutive calls of just bd
should switch back and forth between the previous and current dir.
What do you think? ;-)
Cheers,
Chris.
I couldn't help but notice this repo seems not to have had any commits in over a year, and there are Pull Requests such as #20 that have seemingly not been acknowledged in 8 years as well as open issues such as #15 dating back 9 years.
The latest release 1.02, is now 6 years old.
The script does work as is, but could be improved, along with better usage documentation.
bd works fine for me on debian unstable other than cd bd p
from the examples. It gives me this error:
devil@siductionbox:~/work/Linux-User/CD-Helferlein/Screenies$ cd bd p
/Todo
(where ToDo is a sub-dir of work)
bash: cd: Zu viele Argumente.
which translates to:
bash: cd: too many arguments
Any idea what might be the reason for that?
Let me know if you need any more info
As soon as https://github.com/Homebrew/homebrew-headonly/pull/16 is through, one can install bd with Homebrew using this:
brew tap homebrew/headonly
brew install --HEAD homebrew/headonly/bd
alias bd='cd ..'
$ cd /home/sharedfs/users/xxx2105/sqllib/lib
bd 05
pwd
/home/sharedfs/users/xxx2105/sqllib/lib
This would allow to include bd in the Homebrew core. Right now it has to be in https://github.com/Homebrew/homebrew-headonly/
I tried bd in zsh.
So instead of adding the alias to the .bashrc file, I add it to my .zshrc file
Then I sourced it.
And when i tried to use bd, instead of changing the directory
I'm still in the same directory, and the name has changed, and it's : NEWPWD
Since the updates/acitivity here seems a bit low frequent, I make an issue istead of a PR. (Don't want a fork hanging around for too long.)
—
If you want, you can update your ReadMe with:
***For OS X/macOS***
Using [MacPorts](https://ports.macports.org/port/bd):
```bash
sudo port install bd
```
For OS X/macOS
Using MacPorts:
sudo port install bd
I can't quite get this "bd" thing going, what wrong did I do, see code...
ousodanos@ousodanos-UX360CA:/usr/bin$ chmod +rx bd
chmod: changing permissions of 'bd': Operation not permitted
ousodanos@ousodanos-UX360CA:/usr/bin$ sudo chmod +rx bd
ousodanos@ousodanos-UX360CA:/usr/bin$ sudo echo 'alias bd=". bd -s"' >> /.bashrc$ sudo source /etc/bash_completion.d/bd
ousodanos@ousodanos-UX360CA:/usr/bin$ source /.bashrc$ sudo wget -o /etc/bash_completion.d/bd https://raw.github.com/vigneshwaranr/bd/master/bash_completion.d/bd
ousodanos@ousodanos-UX360CA:/usr/bin$ cd
ousodanos@ousodanos-UX360CA:
ousodanos@ousodanos-UX360CA:
sudo: source: command not found
ousodanos@ousodanos-UX360CA:$ source /etc/bash_completion.d/bd$ cd Downloads/LibreOffice_5.3.2.2_Linux_x86-64_deb/DEBS/
--2017-04-15: command not found
bash: /etc/bash_completion.d/bd: line 2: syntax error near unexpected token (' bash: /etc/bash_completion.d/bd: line 2:
Resolving raw.github.com (raw.github.com)... 151.101.172.133'
ousodanos@ousodanos-UX360CA:
ousodanos@ousodanos-UX360CA:/Downloads/LibreOffice_5.3.2.2_Linux_x86-64_deb/DEBS$ bd Downloads/Downloads/LibreOffice_5.3.2.2_Linux_x86-64_deb/DEBS$
--2017-04-15: command not found
bash: /usr/bin/bd: line 2: syntax error near unexpected token (' bash: /usr/bin/bd: line 2:
Resolving raw.github.com (raw.github.com)... 151.101.172.133'
ousodanos@ousodanos-UX360CA:
I'd really appreciate a quick response here, thanks
Currently completions are ordered alphabetically. Would be nice if there were an option to sort them in the order in which they appear in the path -- so if current working dir is /home/user/Desktop/stuff/
, then autocomplete would go:
$ bd <tab-key><tab-key>
home user Desktop
Should support updating bd by itself or by passing a param
I know this is really minor (and possibly not worth a commit), but my OCD finds it very repetitive that bd
echos the name of the new PWD since it's already in my $PS1
. It would be nice if there was a -q
(quiet) flag that could be added to suppress this echo.
I know that you can just comment out or remove the line, so perhaps this is a frivolous issue, but this would make the update process easier in my opinion (fetch from git instead of fetch and them comment out echo line).
Hi,
I installed bd on Ubuntu 22.04, completely. But when input "bd xxx", it did not jump to the xxx folder, only display the xxx forder info.
Like this,
zhi@:~/workspace/uuu_fw/user/uww/uwwc$ bd user
/home/zhi/workspace/uuu_fw/user/
There is a problem with the sed implementation not handling newlines in replacement strings, and this was causing problems with the bash completion script on the platform.
I have implemented a fix that seems to work on both Mac and Linux, but I have only tested CentOS on the Linux side, so someone may want to do more testing.
Fix is in #33
Wouldn't it be great if bd
could also match substring at any potion?
Use case:
pwd
~/some-repo.git/3rdparty/component/src/include
bd git
pwd
~/some-repo.git
I really love the idea behind bd
, and it comes in handy a lot for me.
Just to let you know, there are some inconsistencies with the way that OS X (BSD's) sed
and other tools work vs. GNU. For instance, the "I" flag on the regex for case sensitivity doesn't work, and in the completion file the sed substitution fails for reasons I don't understand. I was able to fix completion by using tr
instead of sed
:
pwd | tr / "\n"
I ended up redoing it completely, though, and now there's case insensitive completion and replacement, at least on Darwin with Bash 4.3.11.
I spent a long time early this morning trying to figure out a case insensitive way to make the main script work before I realized you had already updated it. Unfortunately, your solution is one of the first ones I had to discard. I could install the GNU utils, but I'd like to think there's a solution for the OS X crowd.
I did give up and write my own version of this utility. It's simpler, but it's suiting my needs. It assumes you always want partial matching and doesn't take all of your logic into account. It uses Ruby to handle the string parsing. A scripting language like Ruby or Perl was the only way I could get it to work for me after spending an hour wrangling around with sed
and awk
. Just sharing it in case you can gleam anything from it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.