huyng / bashmarks Goto Github PK
View Code? Open in Web Editor NEWDirectory bookmarks for the shell
Home Page: https://everyhue.me/posts/bashmarks-directory-bookmarks/
License: BSD 3-Clause "New" or "Revised" License
Directory bookmarks for the shell
Home Page: https://everyhue.me/posts/bashmarks-directory-bookmarks/
License: BSD 3-Clause "New" or "Revised" License
For example, if someone is using Git Bash for Windows, they will not have the ability to run the make
command.
This command could be replaced by a few mkdir
and a cp
.
I was personally able to figure it out on my own, but it would be nice if the commands were simply in the README.
I can't find any license information in Bashmarks. Please add it.
the current function "l" is typically aliased to something else on Ubuntu
What's the recommend way to alter the alias for bashmarks, with modifying the code? i.e. l -> lll
...hasn't anyone does this before. It's genius! You've made my life easier. Thank you.
I love bashmarks. I had been keeping all kinds of aliases in .bashrc and this has changed my life at the terminal.
I'd love to see a feature where the bashmarks can be saved (and executed) as paths relative to ~
. It would make it possible for me to sync .sdirs
between OSes (linux/mac) that have different home directory paths.
Thanks!
Clark
On Linux at rev c40978c
/tmp/1.0 $ s 1.0
/tmp/1.0 $ g 1.0
bash: export: `DIR_1.0=/tmp/1.0': not a valid identifier
bash: cd: .0: No such file or directory
hi,
my home directory has, unfortunately, a space in it. specifically "Macintosh HD". This makes bash marks useable. Aside from renaming the hard drive, is there a fix for this?
examples below:
$ l
-bash: source: /Volumes/Macintosh: is a directory
$ s something
-bash: $SDIRS: ambiguous redirect
$ p something
-bash: source: /Volumes/Macintosh: is a directory
I think this project is perfect to add to homebrew so that Mac users can easily install it. Please consider doing so.
Xin chào
http://www.huyng.com/bashmarks-directory-bookmarks-for-the-shell/
link is dead.
Could you fix it?
error:
root@test:/opt# source /root/.local/bin/bashmarks.sh
: command not found
: command not found
: command not found
-bash: /root/.local/bin/bashmarks.sh: line 45: syntax error near unexpected token $'{\r'' 'bash: /root/.local/bin/bashmarks.sh: line 45:
function s {
my ubuntu uname info:
Linux test|3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
Sorry if this question already aked anywhere... I didn't found it. But can remember that i read something about it in the past.
To share the marks between multiple user... i think it is enough to sync the .sdirs file.
But I would like to know how I've to install Bashmarks to make it usable for all users.
Or did I really have to install it on each user again?
Hi!
I'm unsure as to exactly what causes this but when i use this on my server with zsh and oh-my-zsh installed this happens
http://www.screencast.com/users/flexd/folders/Jing/media/ade8103f-e9fd-4979-a99b-47de78ec2b37
I had the exact same problem with rvm and zsh (if you have heard of rvm, http://rvm.beginrescueend.com/integration/zsh/). To solve that with rvm i had to do "unsetopt auto_name_dirs"
That probably changes some setting inside rvm but should also be a clue on how to fix it? I can take a look at the rvm source to see if i can find a solution but it's going to have to be next week some time. I figured i'd post this here in the mean time so perhaps someone else knew how to fix it or figured it out :-)
Thanks for making such a useful and obvious little feature, can't really see why nobody has thought of this before!
I suggest a change to the architecture.
Make the function names more descriptive. eg. bashmark_jump
instead of g
and so on.
Then alias them.
Take this snippet:
function bashmark_jump() {
# do stuff here
}
# other functions
alias g='bashmark_jump'
alias s='bashmark_save'
# so on
Even better option would be to add the alias definitions in another file or to simply echo it to .bash_aliases
or .bashrc
.
This is merely a suggestion and I don't know how portable this approach will be (zsh, OSX etc.).
I have tested this on bash and it works fine. If you want, I can submit a pull too because that's how I have set it up on my system.
While having set -o noclobber in my .bashrc, bashmarks start to get errors while adding marks
After changing the # purge line in the function _purge_line from
sed "/$2/d" "$1" > "$t"
to
sed "/$2/d" "$1" >| "$t"
it works.
I suggest a function that checks if the noclobber option is set while the script is sourced and adjust the script true a variable if it is.
If a script is run normally the "noclobber" option does not concern but as this script loads with the shell it would be good if it took this option in to concern.
If you're looking for a replacement for this project you can use CDPATH to give you similar functionally.
Hi,
I use bashmarks all the time and it is extremely useful to me.
Feature request: a shortcut to set the current directory as a bookmark without typing the name
I would have a list of directories that function as work places I frequently navigate to. Every time I have to set a bashmark as in
cd my-very-long-working-directory
s myverylongworkingdirectory
cd to-where-I-was-before
The shortcut would be to simply state
s cwd
where cwd is the name of the current working directory that is parsed to remove characters that bashmarks do not allow. The cwd can be anything else, it need not be cwd as long as bashmarks recognise it as the current working directory.
A trivial feature, but one that will be useful to some.
Thanks
Hello,
This is a brilliant tool that saves a lot of time. However, here is a case where it could even work better:
I often have several directories I traverse to in the software project using the marks. However I usually have multiple versions of the project, e.g. /opt/v1/ opt/v2/ /opt/v3/ etc. If I could have relative marks I would not have to re-record all directories when I switch between v1/ and v2 for example.
Maybe while saving a mark, there could be a relative option where we specify the starting point?
Thanks,
Bahadir
Hi everyone,
The default bookmarks file is ~/.config/gtk3.0/bookmarks, it has this format:
file:///filepath bookmark_name
If use the system file, bash bookmarks will be available in a file manager.
Is this behavior intended? After the install 'l' is still short hand for 'ls'.
Maybe add file .description
in path:
s pathname "bla-bla-bla"
and read this file when listing:
l
pathname /media/.../path
bla-bla-bla
pathname2 /media/.../path2
[ cat /media/.../path2/.description ]
pathname3 /media/.../path3
[ cat /media/.../path3/.description ]
...
?
Gurus,
This tool is great, and I think more value can be added if we can show a numbered list, and allow users to jump to a directory based on the number.
This is similar to how you run the history command, you see a numbered list of history commands, and then you can use !n to re run a particular command. Similarly,
$ l
1 foo /Users/roubles/foo
2 bar /Users/roubles/bar
3 fubar /Users/roubles/fubar
4 nada /Users/roubles/nada
5 alice /Users/roubles/git/alice
6 bob /Users/roubles/git/bob
And then users can use something like 'n 5' and jump to /Users/roubles/git/alice.
$ n 5
$ pwd
$ /Users/roubles/git/alice
This simplifies the workflow a lot.
First of all I want to thank you. This is an awesome tool!
However I have issues going to paths with whitespaces such as ~/Library/Application Support/
Setting a path with bashmarks "s" works perfectly but I can't go in that folder with "g".
Sincerely
Ömer Avci
When I type g <tab>
I get g 1:IR_deployer
. My ~/.sdirs
contains export DIR_deployer="$HOME/Sites/deployer"
Sometimes I want to clear all bookmarks. Can you add a d_c option for that?
Maybe even a 'are you sure?' prompt.
The current CLI of s
, g
, d
, l
, and p
takes up single-letter designations that many developers prefer to use for custom aliases. It is also unconventional, in that most *nix CLIs are a single command with option flags for the different actions.
This also causes forward-compatibility issues. For example, if #77 is implemented the current convention would argue for a c
(leanup) command, but this may unexpectedly collide if someone already has a c
alias or function.
Furthermore, the only action that really merits a single-letter designation is the g
command [edit: sorry, I meant 'g', not 'c']. That's the only one that is used enough to warrant the single-letter shortcut. (Navigating to a directory occurs 100x more often than setting, listing, or deleting.)
Thus, I suggest switching the CLI to a single command (e.g. 'mark'), thusly:
Old | New | Comment |
---|---|---|
g |
mark (no options) |
aliased as g |
s |
mark --set or mark -s |
|
d |
mark --delete or mark -d |
|
l |
mark --list or mark -l |
|
p |
mark --print or mark -p |
|
(new) | mark --help or mark -h |
usage and help info |
(new) | mark --legacy |
Creates s , d , l , p aliases (which would not be configured by default) |
(new) | mark --clean or mark -c |
Cleanup. see #77 |
I'm in a UTF-8 environment and a lot of my directories' names have characters above ASCII in them. For many of those it'd be natural to assign bookmark names that also have characters beyond ASCII. For example, my "Desktop" directory is localized as ~/Työpöytä, and I'd like to name that bookmark "työpöytä".
jani@saegusa:Työpöytä$ s työpöytä
bookmark name is not valid
This fails because bashmarks validates names using the regexp /[^A-Za-z0-9_]/
. It's simple enough to patch to account for the 6 additional characters in my Scandinavian locale, but bashmarks also derives an environment variable name from the bookmark name, and apparently Bash does not support UTF-8 for those:
jani@saegusa:~$ LC_MESSAGES=C export DIR_työpöytä=$HOME/Työpöytä/
bash: export: `DIR_työpöytä=/home/jani/Työpöytä/': not a valid identifier
There may be other obstacles as well, those are just the two I could find at a glance.
Obviously I can work around this by not using UTF-8 in bookmark names, but it needlessly increases the mental effort required to recall the names and also the chances of name collisions.
just s
makes the current dir the default g
. Or something like that. Just a default g
would be great. Like cd
defaults to ~/
If you symlink the .sdirs
file to use with something like dotfiles the _purge_line
function breaks the symlink since it moves the file and recreates it
I use yadm to manage my dotfiles across many different systems. The current
mechanism they have for managing files that are different are symlinks, so for
example
.sdirs## <- default
.sdirs##classA <- special one-off system (i.e. different and/or extra bashmarks)
A yadm alt command will link .sdirs --> .sdirs##classA or .sdirs --> .sdirs## based on
configuration.
The current bashmarks will stop on the symlink during a "s" and my guess "d"
Possible solution, to see if SDIRS is a link, if so follow it to the real file
change:
if [ ! -n "$SDIRS" ]; then
SDIRS=~/.sdirs
fi
touch $SDIRS
to
if [ ! -n "$SDIRS" ]; then
SDIRS=~/.sdirs
fi
tmp=$(readlink $SDIRS)
if [ -n "$tmp" ]; then
# echo "Updating sdirs: $tmp"
SDIRS=$tmp
fi
touch $SDIRS
This project would profit greatly from a home-brew integration for easy installation on Macs.
Edit: I forgot I had already requested this :)
Failing silently (by defaulting to the user's home directory) is unexpected and dangerous. For example:
cd nonexistant_dir && rm *
-bash: cd: nonexistant_dir: No such file or directory
# Didn't accidentally delete files in the current directory, yay!
whereas ...
g undefined_alias && rm *
What should happen ...
cd nonexistant_dir && rm *
-bashmarks: g: no alias for 'nonexistant_dir'
# rm command should not execute here
Thanks (again) for a great tool. I've been using this for years and it's an essential part of my workflow.
One thing I've found is that as my work flows from one project to the next and I delete (or move) old projects, many of the bookmarks I've saved become invalid (dead). Cleaning these up is somewhat annoying process. One has to try each bookmark individually to see if it still works and, if not, delete it.
It would be nice if there were a shortcut that would do this as a single command.
It's actually a zsh issue, but can be a problem to it's users.
It writes down "_purge_line:7: file exists:" and does strange things with bookmarks, like overwrites previous or doesn't save new ones.
The problem is with zsh config option NOCLOBBER,
From zsh docs on CLOBBER:
Allows > redirection to truncate existing files, and >> to create files. Otherwise >! must be used to truncate a file, and >>! to create a file.
I'm not a bash ninja, so I can't provide a patch for this issue, I just turned it off in zsh config file
setopt CLOBBER
For some reason, the script accidentally created this bookmark:
$ l
-bash: export: `DIR_apt-605=/Users/marcamillion/folders/some-project': not a valid identifier
How do I get rid of it?
I tried d
and that entire line, but it doesn't work.
Thoughts?
It actually sends me to a prompt, it seems the ``` character is throwing it off:
$ d -bash: export: `DIR_apt-605
> `
-bash: DIR_apt-605: command not found
-bash: d: command not found
The installation could be simplified to a simple curl instead of the clone and make install
curl -o ~/bin/bashmarks.sh https://github.com/huyng/bashmarks/raw/master/bashmarks.sh
echo "source ~/bin/bashmarks.sh" >> ~/.bash_profile # or ~/.bashrc
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.