Skip to content

Commit

Permalink
Update to just use fzf.
Browse files Browse the repository at this point in the history
  • Loading branch information
aubreypwd committed Apr 7, 2023
1 parent b340438 commit ac092b9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Use `fzf` to browse your directories using fuzzy method.

- Requires `fzf`

![Screenshot](screenshot.gif)

## Usage
Expand Down Expand Up @@ -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`.
26 changes: 16 additions & 10 deletions zsh-plugin-fd.plugin.zsh
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit ac092b9

Please sign in to comment.