bm

Lazy bookmark system
git clone git://gtms.dev/bm
Log | Files | Refs | README | LICENSE

bmrm (571B)


      1 #!/usr/bin/env zsh
      2 # Remove bookmarks
      3 #
      4 # Usage: bmls | grep "STRING" | bmrm
      5 
      6 if [[ ! -f ${BOOKMARK} ]]; then
      7   echo "BOOKMARK env is not set or not a file" >&2
      8   exit 1
      9 fi
     10 
     11 while read line; do
     12   founds=$(grep -iFn "$line" < $BOOKMARK)
     13   if [[ -z $founds ]];then
     14     echo "Nothing removed" >&2
     15     exit 1
     16   fi
     17   count=$(wc -l <<< "$founds")
     18   if [[ $count -gt 1 ]]; then
     19     echo "Found more than single line for '${line}':\n" >&2
     20     echo "${founds}"
     21     exit 1
     22   fi
     23   if [[ $count -eq 1 ]]; then
     24     num=("${(@s/:/)founds}")
     25     sed -i "${num[1]}d" $BOOKMARK
     26   fi
     27 done