Skip to content
Discussion options

You must be logged in to vote

Include --search-path roots in fd output (for piping into fzf/tmux)

You can include the search roots themselves alongside their subdirectories so they appear in the stream you pipe to fzf. Two simple approaches:


Option 1 — Prepend the roots (simple & fast)

paths=(~/.dotfiles ~/dev/projects)

sel=$(
  {
    # 1) Emit the roots themselves
    printf '%s\n' "${paths[@]}"
    # 2) Emit discovered subdirectories
    fd -t d -a -H -E .git . --search-path "${paths[@]}"
  } | fzf --prompt="session dir> "
)

[ -n "$sel" ] && tmux new -s "$(basename "$sel")" -c "$sel"

Notes

  • -t d → directories only (good for tmux working dirs).
  • -a → absolute paths (nice for tmux new -c).
  • -H → include hidden entrie…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@alewis001
Comment options

@sergio-santiago
Comment options

Answer selected by alewis001
Comment options

You must be logged in to vote
1 reply
@sergio-santiago
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants