implement bm_remove
this is a barebone implementaion which only accepts line number as argument.
This commit is contained in:
@ -43,11 +43,16 @@ Edit bookmarks.
|
||||
sxbm edit
|
||||
```
|
||||
|
||||
Remove a bookmark.
|
||||
```
|
||||
sxbm rm <line_number>
|
||||
```
|
||||
|
||||
Run `sxbm --help` to see more detailed usage.
|
||||
|
||||
## Todo
|
||||
|
||||
- [ ] Implement remove. Should take same arguments as `open`.
|
||||
- [ ] Enhance `remove` arguments. Should take same arguments as `open`.
|
||||
- [ ] Enhance `edit` arguments. Should take similar arguments as `open`.
|
||||
- [ ] Add a dmenu/rofi wrapper.
|
||||
- [ ] Add PGP encryption.
|
||||
|
||||
19
sxbm
19
sxbm
@ -49,6 +49,7 @@ COMMANDS:
|
||||
add <link> [title] [+tags]
|
||||
ls|list [-s|--strict] [-c|--disable-colors] [title] [+tags]
|
||||
open [-f|--force] <line_num|title|+tags>
|
||||
rm|remove <line_num>
|
||||
edit
|
||||
-h|--help print this text and exit
|
||||
-v|--version print the version and exit\n\n"
|
||||
@ -165,6 +166,22 @@ bm_edit(){
|
||||
$EDITOR "$DATA_FILE"
|
||||
}
|
||||
|
||||
bm_remove(){
|
||||
[ -z "$1" ] && die "No arguments given"
|
||||
|
||||
[ "$1" -eq "$1" 2>/dev/null ] &&
|
||||
LINK=$(sed "$1q;d" $DATA_FILE) ||
|
||||
die "Link not found"
|
||||
|
||||
printf "Delete this link? (y/n)\n$LINK\n"
|
||||
read ANSWER
|
||||
if [ "$ANSWER" = "y" ] || [ "$ANSWER" = "yes" ]; then
|
||||
sed -i --follow-symlinks "$1d" "$DATA_FILE" &&
|
||||
echo "Deleted successfully" ||
|
||||
die "Couldn't delete link"
|
||||
fi
|
||||
}
|
||||
|
||||
############
|
||||
### main ###
|
||||
############
|
||||
@ -189,6 +206,8 @@ case "$1" in
|
||||
bm_open "$@"
|
||||
;;
|
||||
"rm"|"remove")
|
||||
shift
|
||||
bm_remove "$@"
|
||||
;;
|
||||
"edit")
|
||||
shift
|
||||
|
||||
Reference in New Issue
Block a user