Loading...
More Shell Posts
#Leif Messinger#For when you want to search a lot of words in a file fast#Arg 1 is the argument the list of words you want to search#Arg 2 is the file you want to search#-z means that it looks at the file as a whole, just treating newlines a characters.#-r is regex. Needed for $, even tho the documentation says you don't need it. They are liars.#First command replaces all . with \. and all - with \-#Second command takes all newlines and replaces them with )|(#Third command takes the trailing |( and deletes it#Forth command puts a /( at the start#Fith command puts /!d at the end. This tells it to not delete any lines that match the pattern.#The second sed takes the output of the first sed as a command that searches any of the combined words#-f - takes a command from the inputsed -z -r -e 's/\./\\\./g ; s/\-/\\\-/g' -e 's/\n/\)\|\(/g' -e 's/\|\($//' -e 'i/\(' -e 'a/!d' $1 | sed -r -f - $2
#!/bin/bash# Set the directory to searchDIRECTORY="src"# Set the output fileOUTPUT_FILE="testids.txt"# Clear the output file> "$OUTPUT_FILE"# Find all .tsx files in the specified directory and its subdirectoriesfind "$DIRECTORY" -type f -name "*.tsx" | while read -r FILEdo# Search for instances of 'data-testid="testid"' and append them to the output filegrep -o 'data-testid="[^"]*"' "$FILE" >> "$OUTPUT_FILE"# Search for instances of "'data-testid': 'testid'" and append them to the output filegrep -o "'data-testid': '[^']*'" "$FILE" >> "$OUTPUT_FILE"doneecho "Search complete. Test IDs written to $OUTPUT_FILE."
// check versionnode -v || node --version// list installed versions of node (via nvm)nvm ls// install specific version of nodenvm install 6.9.2// set default version of nodenvm alias default 6.9.2// switch version of nodenvm use 6.9.1
# Update all npm packages under the scope defined by the PREFIX variable ("foo").PREFIX="foo"; npm ls | grep "$PREFIX" | awk -F/ '{print $NF}' | sed 's/@.*//' | xargs -I package npm update @"$PREFIX"/package
#!/bin/bash#makefileMaker.sh by Leif Messinger#Needs getDependencies.shCC="gcc"#I have no idea why it's called CXX when it's a c++ compiler#I know that cpp is c pre processor, but still, why X?CXX="g++"CXXFLAGS="-std=c++17 -O2"#CFLAGS="-std=c17"LIBRARIES="$@"#Vulkan Flags for me#LIBRARIES="-lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi"function compileAllFiles(){#output: bruh.o yeet.o# CXX $CXXFLAGS bruh.o yeet.o -o output $LIBRARIESecho -n "output:"if compgen -G "*.cpp" &> /dev/null; thenfor f in *.cpp; doecho -n " ${f%.cpp}.o"donefiif compgen -G "*.c" &> /dev/null; thenfor f in *.c; doecho -n " ${f%.c}.o"donefiecho ""if compgen -G "*.cpp" &> /dev/null; thenecho -e -n "\t$CXX $CXXFLAGS "elseecho -e -n "\t$CC $CFLAGS "fiif compgen -G "*.cpp" &> /dev/null; thenfor f in *.cpp; doecho -n " ${f%.cpp}.o"donefiif compgen -G "*.c" &> /dev/null; thenfor f in *.c; doecho -n " ${f%.c}.o"donefiecho " -o output $LIBRARIES"echo ""}function compileAllObjectFiles(){#bruh.o: bruh.cpp yeet.h# CXX $CXXFLAGS -c bruh.cpp $LIBRARIESif compgen -G "*.cpp" &> /dev/null; thenfor f in *.cpp; doecho -n "${f%.cpp}.o: $f"getDependencies.sh < $fecho ""echo -e "\t$CXX $CXXFLAGS -c $f"echo ""donefi#yeet.o: yeet.c# CC $CFLAGS -c yeet.c $LIBRARIESif compgen -G "*.c" &> /dev/null; thenfor f in *.c; doecho -n "${f%.c}.o: $f"getDependencies.sh < $fecho ""echo -e "\t$CC $CFLAGS -c $f"echo ""donefi}compileAllFilescompileAllObjectFiles#does not work on windowsecho "clean:"echo -e "\trm -f -v *.o output"echo ""echo "run:"echo -e "\t./output"echo ""echo "debug:"if compgen -G "*.cpp" &> /dev/null; thenecho -e -n "\t$CXX $CXXFLAGS -g "elseecho -e -n "\t$CC $CFLAGS -g "fiif compgen -G "*.cpp" &> /dev/null; thenfor f in *.cpp; doecho -n " ${f}"donefiif compgen -G "*.c" &> /dev/null; thenfor f in *.c; doecho -n " ${f}"donefiecho " $LIBRARIES -o output"echo ""
# Run "test" script on all packagesnpm run test --workspaces# Tip - this also works:npm run test -ws----------------------------------------------------# Runs "test" only on package-anpm run test --workspace package-a# Tip - this also works:npm run test -w package-a----------------------------------------------------# Install `lodash` on `package-a`npm install lodash --workspace package-a# Install `tap` on `package-b` as a dev dependencynpm install tap --workspace package-b --save-dev# Install `package-a` on `package-b`npm install package-a --workspace package-b# Install `eslint` in all packagesnpm install eslint --workspaces