diff --git a/README.md b/README.md index 3d6ea47..b102d04 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Use `fzf` to browse your directories using fuzzy method. +- Requires `fzf` + ![Screenshot](screenshot.gif) ## Usage @@ -38,18 +40,4 @@ Install the package on `master`: antigen bundle ssh://git@github.com/aubreypwd/zsh-plugin-fd ``` -...and contribute upstream by working in `$HOME/.antigen/bundles/aubreypwd/zsh-plugin-fd`. - ---- - -## Changelog - -All changelogs beyond these were moved to Github releases. - -### 1.0.1 - -- Tries to install `fzf` for you if using `antigen` method via `brew` - -### 1.0.0 - -- First version +...and contribute upstream by working in `$HOME/.antigen/bundles/aubreypwd/zsh-plugin-fd`. \ No newline at end of file diff --git a/zsh-plugin-fd.plugin.zsh b/zsh-plugin-fd.plugin.zsh index 2795464..a3f5bab 100644 --- a/zsh-plugin-fd.plugin.zsh +++ b/zsh-plugin-fd.plugin.zsh @@ -1,27 +1,33 @@ -#!/bin/zsh +#!/bin/sh -if [[ $(command -v require) ]]; then - require "fzf-tmux" "brew reinstall fzf" "brew" # Automatically install fzf using homebrew. +### + # shellcheck disable=SC2006,SC2035,SC2086 + ## + +if [ "$(command -v require)" ]; then + require "fzf" "brew reinstall fzf" "brew" # Automatically install fzf using homebrew. fi ### # Similar to cd, but using fzf. # - # E.g: fd + # E.g: fd [number] # # @since Wednesday, 9/11/2019 + # ## -function fd { +fd () { - if ! [[ -x $(command -v fzf) ]]; then >&2 echo "Please install fzf (specifically fzf-tmux) to use fd." && return; fi - if ! [[ -x $(command -v find) ]]; then >&2 echo "Requires find command." && return; fi + if ! [ -x "$(command -v fzf)" ]; then >&2 echo "Please install fzf to use fd." && return 1; fi + if ! [ -x "$(command -v find)" ]; then >&2 echo "Requires find command." && return 1; fi - local DEPTH=0 + DEPTH=0 if [ -n "$1" ]; then DEPTH="$1" fi + DIR=`find -L * -maxdepth $DEPTH -type d -print 2> /dev/null | fzf --height=100%` \ + && cd "$DIR" || return 1 - local DIR=`find -L * -maxdepth $DEPTH -type d -print 2> /dev/null | fzf-tmux` \ - && cd "$DIR" + return 0 }