-
-
Save cirrusUK/8247de25724497e7ed3817de76e9f7fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################ | |
# rf | |
# open files, cd into directories and stuff | |
# not the most intuitively written bash script but it werks hehe | |
# made by theo | |
################################################################ | |
export opener="piper" | |
# export opener="rifle" (i use rifle, so) | |
fzf="fzf -e --tac --reverse --border=sharp --ansi --color=bg+:#073642,bg:#002b36,spinner:#719e07,hl:#586e75 --color=fg:#839496,header:#586e75,info:#cb4b16,pointer:#719e07 --color=marker:#719e07,fg+:#839496,prompt:#719e07,hl+:#719e07 --border=sharp --prompt=➤ --pointer=➤ --marker=➤ " | |
################################################################ | |
depcheck() { | |
if [[ -z $(command -v fzf) ]]; then | |
printf "install fzf.\ | |
\nfzf is required for this script to function."\ | |
&& exit 0; fi;} | |
################################################################ | |
displayhelp() { | |
printf " | |
rf: open files, cd into directories and stuff | |
using find and fzf. | |
usage: rf [options] | |
OPTIONS | |
=> no arguments \n\t open files via \$opener. (rifle is set as default) | |
=> -l \n\t open files but don't close fzf. | |
=> -d \n\t open directories in a subshell. | |
=> -h / --help \n\t display help text. | |
=> -z \n\t search for files and open the directory in which they are located.\n\n";} | |
################################################################ | |
depcheck | |
################################################################ | |
case $1 in | |
"") find / -type f 2>/dev/null | $fzf --bind=enter:execute'($opener {})' --bind=enter:+close ;; | |
-l) find / -type f 2>/dev/null | $fzf --bind=enter:execute'($opener {})' ;; | |
-d) folder="$(find / -type d 2>/dev/null | $fzf)" && cd "$folder" && \ | |
echo "Press Ctrl+d to exit the subshell" && $SHELL ;; | |
-h|--help) displayhelp ;; | |
-z) folder="$(find / -type f 2>/dev/null | $fzf)" && \ | |
cd "$(dirname $folder)" && \ | |
echo "Press Ctrl+d to exit the subshell" && $SHELL ;; | |
esac | |
################################################################ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment