Skip to content

Commit

Permalink
feat: extend fzf functions in zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
adamtabrams committed May 27, 2020
1 parent a7ae8e8 commit c9b424d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 deletions.
45 changes: 39 additions & 6 deletions home/.config/zsh/alias.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,58 @@ bak() { cp -r "$1" "$1.bak" }
unbak() { mv "$1" $(sed "s/.bak$//" <<< "$1") }

#### Fzf #########################################
# go to one of the lastest dirs
gl() {
goto=$(cat "$DIRSTACKFILE" | fzf --reverse)
[ "$goto" ] && cd "$goto"
}

# go to a repo
gr() {
repo="$(cd ~/repos && fd -d1 | fzf --reverse)"
[ "$repo" ] && cd "$HOME/repos/$repo"
}

# open a repo in the browser
or() {
prev_dir=$(pwd) && gr && hub browse; cd "$prev_dir"
}

# use lazygit on one or more repos
lr() {
for repo in $(cd ~/repos && fd -d1 | fzf --reverse --multi); do
lazygit -p "$HOME/repos/$repo"
done
}
gw() {
wiki=$(cd ~/.local/vimwiki && fd | fzf --reverse)
[ "$wiki" ] && $EDITOR "$HOME/.local/vimwiki/$wiki"

# go to a dir in temp
gt() {
dir="$(cd ~/temp && fd -t d | fzf --reverse)"
[ "$dir" ] && cd "$HOME/temp/$dir"
}
gl() {
goto=$(cat "$DIRSTACKFILE" | fzf --reverse)
[ "$goto" ] && cd "$goto"

# edit a file in temp
et() {
file="$(cd ~/temp && fd -t f | fzf --reverse)"
[ "$file" ] && "$EDITOR" "$HOME/temp/$file"
}

# go to a dir in save
gs() {
dir="$(cd ~/save && fd -t d | fzf --reverse)"
[ "$dir" ] && cd "$HOME/save/$dir"
}

# edit a file in temp
es() {
file="$(cd ~/save && fd -t f | fzf --reverse)"
[ "$file" ] && "$EDITOR" "$HOME/save/$file"
}

# edit a vimwiki page
ew() {
wiki=$(cd ~/.local/vimwiki && fd | fzf --reverse)
[ "$wiki" ] && "$EDITOR" "$HOME/.local/vimwiki/$wiki"
}

#### Save lf Dir #################################
Expand Down
8 changes: 5 additions & 3 deletions home/.fdignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**/.DS_Store
**/.git
**/.gitignore

/Applications
/Desktop
/Documents
Expand All @@ -14,6 +18,4 @@
/.*
!/.config

**/.DS_Store
**/.git
**/.gitignore
/temp/OLD

0 comments on commit c9b424d

Please sign in to comment.