huyng/bashmarks

Function names conflict with fasd. Suggestion to a new script design... Read details.

hashhar opened this issue · 2 comments

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.

sam3k commented

I can confirm that this is an issue on my Mac running ZSH/Oh-my-zsh where I get the following outputs:

l # outputs the equivalent of `ls -la`
d # oh-my-zsh's `dirs -v` (lists last used directories)
g # oh-my-zsh's list or define global aliases

IMHO, these shortcuts should be optional and by default it should force you to use more unique commands like bashmark_jump as suggested above. It is always easy to add short aliases in your bash profile.

Either way, man, what an awesome script. =_)

sam3k commented

Upon taking a look at the source code, I noticed that an alternative shortcut is already offered for listing: _l. Beautiful! Now, the only shortcut not working is d for which i simply added a similar shortcut.

Open /usr/local/opt/bashmarks/libexec/bashmarks.sh in your editor and add:

function _d {
    check_help $1
    _bookmark_name_valid "$@"
    if [ -z "$exit_message" ]; then
        _purge_line "$SDIRS" "export DIR_$1="
        unset "DIR_$1"
    fi
} 

Save and source the file ( source /path/to/bashmarks.sh ). Now you can delete a bookmark by typing _d <bookmark_name>.

The code above was an exact copy of the function d.