function opens(){
if [[ $# -eq 0 ]]; then
elif [[ $# -eq 1 ]]; then
open "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$1 | tail -1)"
else
hello_var=$(echo -n "$1")
minus_var=$(echo -n "$2")
count_=0
for i in {$hello_var..$minus_var}
do
second_var="$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$i | tail -1)"
array=( .csv .docx .scpt .xlsx .ipynb .rtf)
for i_2 in "${array[@]}"
do
if [[ $second_var =~ "$i_2" ]]; then
let count_++
fi
done
if [ $count_ -eq 0 ];then
open -a "google chrome" "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$i | tail -1)"
fi
count_=0
echo "($i) " "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$i | tail -1)"
sleep 1
done
fi
}
function f() {
if [[ $# -eq 0 ]]; then
find . -maxdepth 2 -type f -not -path '*/\.*' | sort > /Users/username/desktop/macbook_pro_scripts/echo_files/open_test.txt
cat -b /Users/username/desktop/macbook_pro_scripts/echo_files/open_test.txt
else
``
fi
}
The Function f will display the files in the current directory up to 2 levels in a list with numbers.
Then you can choose to open the files based on the number with "opens 1 5",
Which means open the first file to the fifth file.