From fdbc141b6cd783358d785c9245796aec0ce9cffe Mon Sep 17 00:00:00 2001 From: Tru Date: Tue, 21 Mar 2023 01:45:11 +0800 Subject: [PATCH] Updated Examples (markdown) --- Examples.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Examples.md b/Examples.md index 59280d3..e232ea0 100644 --- a/Examples.md +++ b/Examples.md @@ -1642,11 +1642,16 @@ function cd() { like normal autojump when used with arguments but displays an fzf prompt when used without ```sh j() { - if [[ "$#" -ne 0 ]]; then - cd $(autojump $@) - return + local preview_cmd="ls {2}" + if command -v exa &> /dev/null; then + preview_cmd="exa -l {2}" + fi + + if [[ $# -eq 0 ]]; then + cd "$(autojump -s | sort -k1gr | awk '$1 ~ /[0-9]:/ && $2 ~ /^\// {print $1 " " $2}' | fzf --height 40% --reverse --inline-info --preview "$preview_cmd" --preview-window down:50% | awk '{print $2}')" + else + command autojump "$@" fi - cd "$(autojump -s | sort -k1gr | awk '$1 ~ /[0-9]:/ && $2 ~ /^\// { for (i=2; i<=NF; i++) { print $(i) } }' | fzf --height 40% --reverse --inline-info)" } ```