Created
June 11, 2022 04:57
-
-
Save firedynasty/b9d180a26b75177c8523df5f9706470a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function u() { | |
| if [[ $# -eq 0 ]]; then | |
| hello_var=$(cat /Users/home/desktop/macbook_pro_scripts/count_open.txt) | |
| #first create a text file in this directory | |
| #write a number into the file | |
| #then will read the number from this file as a variable | |
| second=$hello_var | |
| let second++ | |
| # every time u is pressed will increase the count | |
| echo -n $second > /Users/home/desktop/macbook_pro_scripts/count_open.txt | |
| # will display the file # in the Terminal | |
| open "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$second | tail -1)" | |
| # will open the file depending on the # on the list | |
| # if count_open.txt has 0 then it will open the first file on the list | |
| # (since computers start counting at 0) | |
| echo "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$second | tail -1)" | |
| # display the file to be opened in Terminal | |
| osascript -e "tell application \"Terminal\" to activate"; osascript -e "tell application \"System Events\" to key code 32" | |
| # this short script allows you to go back to Terminal | |
| # delete if not needed, helps with my workflow | |
| else | |
| echo -n $1 > /Users/home/desktop/macbook_pro_scripts/count_open.txt | |
| # otherwise, if you write 'u and a # then can reset the count' | |
| fi | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment