Skip to content

Instantly share code, notes, and snippets.

@firedynasty
Created August 13, 2021 00:35
Show Gist options
  • Save firedynasty/7d7c79b466b8453fb1e6d5ef0a0b8ce7 to your computer and use it in GitHub Desktop.
Save firedynasty/7d7c79b466b8453fb1e6d5ef0a0b8ce7 to your computer and use it in GitHub Desktop.
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-.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment