aboutsummaryrefslogblamecommitdiffstats
path: root/batnote
blob: a050e872552b568b586cd587f1c092824f756619 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                                                

                                 
                

                   

                




                                 


          
 




                                                           
                                                      

                  
                     
          


                                                                                   

  






                                                                          
 


                        
 
                                                                                 
                                                                                    
#!/bin/bash

# a script for FZFing through my Notes folder for quick reading.
# Uses bat if installed, otherwise will use less.

NOTES=/home/$USER/Documents/Notes
FZF_BIN=/usr/bin/fzf
BAT=/usr/bin/bat
CAT=/usr/bin/cat
#LESS=/usr/bin/less
VIM=/usr/bin/vim

# it is batcat on Debian hosts
if [[ -x /usr/bin/batcat ]]; then
    BAT=/usr/bin/batcat
fi

set -e

CMD="$BAT"

if ! [[ -x $FZF_BIN ]]; then
    echo "You need to have FZF installed for this to work."
    exit 1
fi

# instead of viewing with less, we want to edit in Vim
if [[ $1 = "-v" ]]
then
  echo "Using vim..."
  CMD=$VIM
  # Thanks to https://stackoverflow.com/a/1489405 for the find command to omit .git
  $CMD "$(find $NOTES -name '.git*' -type d -prune -o -type f -print|$FZF_BIN)"
  exit
fi

# if [[ -z $1 ]]; then
#     echo "You must provide a file name as the argument to this command."
#     exit 1
# else
#     TARGET=$1
# fi


# if [[ -x $BAT ]]; then
#     CMD=$CAT
# fi

# Thanks to https://stackoverflow.com/a/1489405 for the find command to omit .git
clear; $CMD "$(find $NOTES -name '.git*' -type d -prune -o -type f -print|$FZF_BIN)"