SHARE
TWEET

Untitled

a guest Sep 17th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fzf-default() {
  2.   fzf --multi --ansi --select-1 --exit-0 --reverse --height '40%'
  3. }
  4.  
  5. function fzf-cd() {
  6.   local DIR=$(fd --type d | fzf +m --ansi --select-1 --reverse)
  7.   if [ -n "$DIR" ]; then
  8.     cd $DIR
  9.   fi
  10. }
  11.  
  12. function fzf-ag() {
  13.   if [ -z "$1" ]; then
  14.     echo 'Usage: agg PATTERN'
  15.     return 0
  16.   fi
  17.   local result=`ag $1 | fzf`
  18.   local line=`echo "$result" | awk -F ':' '{print $2}'`
  19.   local file=`echo "$result" | awk -F ':' '{print $1}'`
  20.   if [ -n "$file" ]; then
  21.     vi $file +$line
  22. fi
  23. }
  24.  
  25. function fzf-vi() {
  26.   fd ${1:-.} | fzf-default | xargs -o vi
  27. }
  28.  
  29. alias d='fzf-cd'
  30. alias g="fzf-ag"
  31. alias v='fzf-vi'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top