Code Monkey home page Code Monkey logo

cd-bookmark's People

Contributors

mollifier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ky0on erikw

cd-bookmark's Issues

Support XDG Base Directory Specification

First of all, thanks for this really great shell enhancer. I use it every day!

Background

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:

  • No polluted $HOME/
  • Can easily grep for only config files in $XDG_CONFIG_HOME
  • Can decide where to store configurations in more complex setups (multi system setup e.g.)
  • Easily wipe state by removing $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.

How

Specifically for this project, this should mean that the search for the configuration file should be done like:

  1. If $CD_BOOKMARK_FILE is set, use this directly
  2. NEW If $XDG_CONFIG_HOME is set, look for $XDG_CONFIG_HOME/cd-bookmark/bookmarks
  3. NEW elseIf $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
  4. else fall-back to current legacy $HOME/.cdbookmark

The first two new steps to can be codifed in bash like:
${XDG_CONFIG_HOME:-$HOME/.config}/cd-bookmark/bookmarks

Support Bash

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:

  • Support use case for those, like me, need to switch between zsh and bash
  • But even more importantly, the potential user base becomes a lot larger by supporting bash too!

Add delete command "cd-bookmark -d BOOKMARK_ID"

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).

Bug: relative completion lists multiple duplicates of each item

Problem description

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.

Leads

With some debug printing I noticed that this function is called multiple times, maybe correlating with the numer of duplicates?

cd-bookmark/_cd-bookmark

Lines 57 to 61 in 27a8863

_cd-bookmark_expand_bookmark_id() {
local bookmark_id="${IPREFIX%/}"
local real_path="$(_call_program cd-bookmark-expand-id cd-bookmark -p "$bookmark_id")"
_path_files -W "$real_path" -/
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.