Loading...
More Shell Posts
## Austin Leath# checks for /Desktop symlink. Creates the symlink if it doesnt already exist##Fetch the target user if desired, otherwise use the currently logged in user.if [ "$4" != "" ]; thenTARGET_USER=$4elseTARGET_USER=$3fiif [ "$5" != "" ]; thenDIRECTORY_NAME=$5elseTARGET_USER="$3 Desktop"fi# FunctionsCHECK_SYMLINK() {if test -f "/Desktop"; thenecho "/Desktop exists"elseecho "/Desktop does not exist"fi}CHECK_SYNTHETIC_CONF() {if test -f "/etc/synthetic.conf"; thenecho "/etc/synthetic.conf exists"elseecho "/etc/synthetic.conf does not exist"fi}CREATE_SYMLINK() {if [[ $(CHECK_SYNTHETIC_CONF) != "/etc/synthetic.conf exists" ]]; thenecho "/etc/synthetic.conf does not exist. creating.."touch /etc/synthetic.confchown -R root:wheel /etc/synthetic.conffiif grep -q "$DIRECTORY_NAME" /etc/synthetic.conf; thenecho "$DIRECTORY_NAME already exists"exit 1elseecho "$DIRECTORY_NAME\t/Users/$TARGET_USER/Desktop" >> /etc/synthetic.conffiecho "/Desktop symbolic link created"}if [[ $(CHECK_SYMLINK) != "/Desktop exists" ]]; thenCREATE_SYMLINKfiexit 0
# 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
awk '\{ for (i=1; i<=NF; i++) { ++D[$i]; } }\END { for (i in D) { print i, D[i] } }\' words.txt | sort -nr -k 2
name="John"echo ${name}echo ${name/J/j} #=> "john" (substitution)echo ${name:0:2} #=> "Jo" (slicing)echo ${name::2} #=> "Jo" (slicing)echo ${name::-1} #=> "Joh" (slicing)echo ${name:(-1)} #=> "n" (slicing from right)echo ${name:(-2):1} #=> "h" (slicing from right)echo ${food:-Cake} #=> $food or "Cake"
#!/bin/bash#Takes all the c and h files in the current directory and prints them#Yup, it's that easyfor file in *.h *.hpp *.c *.cpp; do#If it existsif [ -f "$file" ]; thenecho "//===============$file==============="cat $filefidone
#!/bin/bash#Changes the remote url from https to ssh.#Only works for github, because I'd have to store a dictionary of every https to ssh url otherwise.#Made using Bing Chat# Get the remote URL from the consoleREPO_URL=$(git config --get remote.origin.url)# Check that REPO_URL contains https://github.comif [[ $REPO_URL == *"https://github.com"* ]]; then# Replace https with ssh in the URL# Change the remote URL to the SSH versiongit remote set-url origin "$REPO_URL"elseecho "Error: REPO_URL does not contain https://github.com" >&2exit 1fi