Hacker News new | comments | show | ask | jobs | submit login

I set my version up with a -f on the unmark rm so that I don't need to be prompted to remove it. Also added some basic completion for both jump and unmark

  export MARKPATH=$HOME/.marks
  function jump { 
      cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1"
  }
  function mark { 
      mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
  }
  function unmark { 
      rm -if $MARKPATH/$1 
  }
  function marks {
      ls -l $MARKPATH | sed 's/  / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo
  }

  _completemarks() {
      local curw=${COMP_WORDS[COMP_CWORD]}
      local wordlist=$(find $MARKPATH -type l -printf "%f\n")
      COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
      return 0
  }

  complete -F _completemarks jump unmark



The purpose of the -i flag is to prompt the user before deleting. Mixing the -i and -f flags is a little moot.

Try removing the -i option to obtain what you want.


Didn't catch that, it was a quick hack of an edit, thanks.


I recommend avoiding -f on rm if you can. Make one mistake and it can be painful. In this case think removing the -i from the unmark function will accomplish what you want.

I made something to the OP's system for the same reason of disdain for super deep trees at work. I'll make a gist and edit this post with it in a few minutes.

Edit: https://gist.github.com/desertmonad/6258429

I like the OP's idea of using symbolic links. That makes it more generally useful (i.e. a gui app can use those simple paths too). I may switch over to that.


Why not use unlink?


What's the advantage?


Nice job! I had to modify _completemarks() function though to work on OSX.

  _completemarks() {
    local curw=${COMP_WORDS[COMP_CWORD]}
    local wordlist=$(find $MARKPATH -type l -exec basename {} \;)
    COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
    return 0
  }


nice additions. For OSX I had to modify the local wordlist part of the auto complete function to read:

local wordlist=$(ls $MARKPATH)


The variable expansions really ought to be quoted, like this:

  function unmark {
      rm -if "$MARKPATH/$1"
  }
Otherwise you are asking for much sadness.




Applications are open for YC Winter 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: