Created
April 8, 2023 20:24
-
-
Save firedynasty/11031caecdb65fb184320687ff39b22e to your computer and use it in GitHub Desktop.
using a bash function to better navigate your files, deep work
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 study() { | |
if [[ $# -eq 0 ]]; then | |
if [ -e study.txt ]; then | |
#If there are no arguments, the function checks whether a file named "study.txt" exists in the current directory. | |
#If it exists, it writes the current working directory to a file named "study_dir.txt" on the user's desktop | |
#and displays the contents of "study.txt" with line numbers. | |
echo $PWD > /Users/username/desktop/macbook_pro_scripts/echo_files/study_dir.txt | |
cat -n study.txt | |
else | |
hello_var=$(cat /Users/username/desktop/macbook_pro_scripts/echo_files/study_dir.txt) | |
cd $hello_var | |
study_file='/study.txt' | |
cat -n $hello_var$study_file | |
echo $hello_var | |
fi | |
else | |
#will take one argument which is a number and will run the command in that line | |
my_variable=$(sed -n "$1p" study.txt) | |
eval "$my_variable" | |
#echo $my_variable | pbcopy | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment