mollifier / cd-bookmark Goto Github PK
View Code? Open in Web Editor NEWzsh plugin to bookmark directories to cd.
License: MIT License
zsh plugin to bookmark directories to cd.
License: MIT License
First of all, thanks for this really great shell enhancer. I use it every day!
Lately the XDG Base Directory Specification has been gaining quite a steady popularity, even though it's been around for a long time already. The basic idea is to standardize where programs put their files e.g. all config files in a certain directory. The benefits for end users are many, including:
$XDG_CONFIG_HOME
$XDG_STATE_HOME
or even $XDG_DATA_HOME
, but without destroying and configuration files.The first point is maybe what most end users enjoy the most though.
Specifically for this project, this should mean that the search for the configuration file should be done like:
$CD_BOOKMARK_FILE
is set, use this directly$XDG_CONFIG_HOME
is set, look for $XDG_CONFIG_HOME/cd-bookmark/bookmarks
$XDG_CONFIG_HOME
is unset, use the default value for the envvar which is $HOME/.config
. Thus, the config file to look for is at $HOME/.config/cd-bookmark/bookmarks
$HOME/.cdbookmark
The first two new steps to can be codifed in bash like:
${XDG_CONFIG_HOME:-$HOME/.config}/cd-bookmark/bookmarks
It would be great if this plugin would additionally support bash. Even though zsh is the default shell for me, at times I need to jump back to a bash session. I have configured my zsh and bash to share the greatest common intersection of config so they work practically the same for me.
Benefits:
It would be convenient to be able to delete a bookmark by name from the cli tool.
As I migrated from huyng/bashmarks, I have aliases like
alias g='cd-bookmark -c'
alias s='cd-bookmark -a'
alias l='cd-bookmark -l'
alias e='cd-bookmark -e'
alias p='cd-bookmark -p'
Thus, to get the delete feature I have made myself a
function d() {
local name="$1"
sed -i "/^${name}|/d" ${CD_BOOKMARK_FILE:-$HOME/.cdbookmark}
}
However it would be a lot nicer if we had a
$ cd-bookmark -d BOOKMARK_ID
command! (then I could just do alias d='cd-bookmark -d
).
e.g.
$ mkdir "blank blank"
$ cd blank\ blank
$ cd-bookmark -a test
$ cd ..
$ cd-bookmark test
cd-bookmark: no such directory: /Users/Uduse/blank
Try `-h' option for more information.
I just discovered the cool feature (27a8863) of relative completion. However it seems like there is also a bug: each completed relative path is listed multiple times for my bookmark home
:
$ cd-bookmark -c home/<tab>
Applications/ Documents/ Movies/ Music/ Public/ dl/
Applications/ Documents/ Movies/ Pictures/ bak@ dl/
Applications/ Documents/ Movies/ Pictures/ bak@ dl/
Applications/ Documents/ Movies/ Pictures/ bak@ dl/
Applications/ Documents/ Movies/ Pictures/ bak@ dl/
Desktop/ Downloads/ Movies/ Pictures/ bak@ doc@
Desktop/ Downloads/ Music/ Pictures/ bak@ doc@
Desktop/ Downloads/ Music/ Public/ bak@ doc@
Desktop/ Downloads/ Music/ Public/ bin/ doc@
Desktop/ Library/ Music/ Public/ bin/ doc@
Desktop/ Library/ Music/ Public/ bin/ doc@
Desktop/ Library/ Music/ Public/ dl/
Tested on zsh 5.8
on macOS 12.0.1
.
With some debug printing I noticed that this function is called multiple times, maybe correlating with the numer of duplicates?
Lines 57 to 61 in 27a8863
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.