Skip to content

Commit

Permalink
Make path as variable suffix as fd do
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Aug 16, 2024
1 parent 9825d78 commit f73a34f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
1 change: 0 additions & 1 deletion pkgs/walk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ pkgs.writeShellApplication rec {
fzf
fd
bat
getoptions
];
}
26 changes: 10 additions & 16 deletions pkgs/walk/walk.bash
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
parser_definition() {
setup REST help:usage -- "Usage: walk [options]... [arguments]..." ''
msg -- 'Options:'
# Don't use $PWD to avoid printing needless absolute path for current directory
option WALK_FROM -d --working-directory on:"/tmp" -- "Working Directory"
disp :usage --help
}
if [ $# -ge 1 ]; then
query="$1"
shift
else
query=""
fi

eval "$(getoptions parser_definition) exit 1"

# if [ $# -ge 1 ]; then
# query="$1"
# else
# query=""
# fi
# Don't use $PWD to avoid printing needless absolute path for current directory
# So use '.' or fd command defaults

# shellcheck disable=SC2016
fd --type f --hidden --follow --exclude .git . "$WALK_FROM" |
fzf --query "$@" --preview 'bat --color=always {}' --preview-window '~3' --bind 'enter:become(command "$EDITOR" {})'
fd --type f --hidden --follow --exclude .git . "$@" |
fzf --query "$query" --preview 'bat --color=always {}' --preview-window '~3' --bind 'enter:become(command "$EDITOR" {})'

0 comments on commit f73a34f

Please sign in to comment.