ed (757B)
1 #!/usr/bin/env bash 2 3 # ed: edit files with your $EDITOR 4 # 5 # Opens a file with your $EDITOR. If no argument is given then it opens the 6 # whole directory into a tree view, or if there is a vim session file run that. 7 # If there is only a few files in the current directly then it just opens all 8 # of them. If given directory open the files within 9 10 VIM_SESSION="Session.vim" 11 12 if [[ "$@" == "" ]]; then 13 if [ -f $VIM_SESSION ]; then 14 $EDITOR -S $VIM_SESSION # open vim session file 15 elif [[ $(ls -l | wc -l) -le 5 ]]; then 16 $EDITOR ./* # if less than 5 files in cwd open all of them 17 else 18 $EDITOR . # open directory 19 fi 20 else # open files/directory given 21 if [ -d "$1" ]; then 22 $EDITOR $1/* # if given directory open files within 23 else 24 $EDITOR "$@" 25 fi 26 fi