diff --git a/README.md b/README.md index ee449b9..0d667cc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,10 @@ its a script that does everything awesome at all times tmux-sessionizer [] ``` +### Changing search paths +```bash +export TMUX_SESSIONIZER_PATHS="~/projects ~/work" +``` + if you execute tmux-sessionizer without any parameters it will assume FZF and try to fuzzy find over a set of directories. - -TODO: waiting on that directory list to be dynamic :) (go a head make pr if you want) diff --git a/tmux-sessionizer b/tmux-sessionizer index fa1bec5..59917ad 100755 --- a/tmux-sessionizer +++ b/tmux-sessionizer @@ -19,12 +19,22 @@ hydrate() { fi } +expand_paths() { + local paths="$1" expanded="" + for path in $paths; do + # Expand ~ to $HOME before passing to `realpath`. + expanded="$expanded $(realpath -m "${path/#\~/$HOME}" 2>/dev/null)" + done + + echo "$expanded" +} + if [[ $# -eq 1 ]]; then selected=$1 else - # If someone wants to make this extensible, i'll accept - # PR - selected=$(find ~/ ~/personal ~/personal/dev/env/.config -mindepth 1 -maxdepth 1 -type d | fzf) + # Use TMUX_SESSIONIZER_PATHS if set, otherwise default paths. + paths=$(expand_paths "${TMUX_SESSIONIZER_PATHS:-"~/ ~/personal ~/personal/dev/env/.config"}") + selected=$(find $paths -mindepth 1 -maxdepth 1 -type d 2>/dev/null | fzf) fi if [[ -z $selected ]]; then