function p() {
if [[ $# -eq 0 ]]; then
hello_var=$(cat /Users/username/desktop/macbook_pro_scripts/echo_files/count_open.txt)
second=$hello_var
let second++
echo -n $second > /Users/stanleytan/desktop/macbook_pro_scripts/echo_files/count_open.txt
open "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$second | tail -1)"
echo "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$second | tail -1)"
else
fi
}
function p-() {
if [[ $# -eq 0 ]]; then
hello_var=$(cat /Users/username/desktop/macbook_pro_scripts/echo_files/count_open.txt)
second=$hello_var
let second++
echo -n $second > /Users/username/desktop/macbook_pro_scripts/echo_files/count_open.txt
open "$(find . -type f -maxdepth 1 -not -path '*/\.*' | sort | head -$second | tail -1)"
echo "$(find . -type f -maxdepth 1 -not -path '*/\.*' | sort | head -$second | tail -1)"
else
fi
}
function p0() {
echo -n 0 > /Users/username/desktop/macbook_pro_scripts/echo_files/count_open.txt
}
In function p() count_open records the # to keep track of the files, so I can open a file starting from 1.
Using the same function I can open files in a folder like flipping through notebook.
So in the command line $: p
If I want to only open files within the same folder and not of its subdirectory I use p-.