Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more CLI commands #63

Open
erikw opened this issue Jun 3, 2023 · 0 comments
Open

Provide more CLI commands #63

erikw opened this issue Jun 3, 2023 · 0 comments

Comments

@erikw
Copy link

erikw commented Jun 3, 2023

Hi, first off, thanks for a fantastic tool, I've used it with great joy for some 1-2 years!

Many many years ago, like 10-13 or so, I started using bashmarks which provide some very neat one-letter shell commands like g mark, s mark etc.

Through the years I've used different shell bookmarks tools like jump & cd-bookmark and I've always kept the original bashmark-style commands by creating similar aliases to the other bookmarking tools, as they are so convenient!

fzf-marks stared a new area of bookmarking, with the interactive menu. When searching for a bookmark I don't know the exact name of, the the fzf interactive menu is perfect! When I know the exact name, it's often easier and faster to use a direct command.

Thus I've used aliases & functions also with fzf-marks, in the style of Bashmarks. This is what I have in my shell startup file:

alias g='fzm'                   # Jump to mark (provided as argument)
alias s='mark'                  # Save current dir as mark (provided as argument)
alias e="vi $FZF_MARKS_FILE"    # Edit bookmarks file. 
alias l="sort $FZF_MARKS_FILE"  # List all bookmarks

_fzf_marks_delete() {
  local mark="$1"
  
  if ! grep -q "^$mark : " $FZF_MARKS_FILE; then
	  echo "$mark is not in the bookmarks" >&2
	  return 2
  fi
  sed -i.bak -e "/^${mark} : /d" "$FZF_MARKS_FILE" && rm "$FZF_MARKS_FILE.bak"
}
alias d='_fzf_marks_delete'  # Delete mark (provided as arg)

_fzf_marks_print() {
  local mark="$1"
  
  if ! grep -q "^$mark : " $FZF_MARKS_FILE; then
	  echo "$mark is not in the bookmarks" >&2
	  return 2
  fi
	  grep "^$mark :" $FZF_MARKS_FILE | awk '{print $3}'
  }
alias p='_fzf_marks_print'  # Print a mark (provided as arg)

This works, but it would be neat if there was built-in support by this tool to do operations like edit, list and delete a mark!

Note: I'm not requesting that this tool should adopt the bashmark-style command names like g, s etc., that I can always create myself, but a requst to provide some switches or subcommands to fzfm or mark to do this. Maybe mark -d abookmark could delete a bookmark named abookmark for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant