Loading...
More Shell Posts
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"
// 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
## 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
#!/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
#!/bin/shBAT_LOW=15BAT_CRITICAL=5if [ "$1" = "--help" ]thenprintf "Usage:\tbattery_check.sh warning%% hibernate%%Description:\tA script for notifying the user via dunst and logging when\tthe battery is low and the system is going to hibernate.\tCan be supplied arguments for the battery low warning and\thibernation percentage thresholds as the first and second arguments.\t Default behavior is to warn at 15% and hibernate at 5%."exitfiif [[ -n "$1" && -n "$2" && $1 -gt $2 ]]thenBAT_LOW=$1BAT_CRITICAL=$2fiacpi -b | awk -F'[,:%]' '{print $2, $3}' | {read -r status capacityecho Low threshold: $BAT_LOW, Hibernate threshold: $BAT_CRITICALecho Status: $status, Capacity: $capacityif [ "$status" = Discharging -a "$capacity" -le $BAT_CRITICAL ]; thenecho Battery critical threshold.dunstify -u critical "Critical battery threshold, hibernating..."logger "Critical battery threshold, hibernating..."sleep .5systemctl hibernateexitfiif [ "$status" = Discharging -a "$capacity" -le $BAT_LOW ]; thenecho Battery low threshold.dunstify -u critical 'Battery low! System will hibernate at 5%.'logger 'Battery low! System will hibernate at 5%.'sleep .5light -S 15exitfi}
# 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