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
| #!/usr/bin/env bash | |
| user=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser;import sys;username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0];username = [username,""][username in [u"loginwindow", None, u""]];sys.stdout.write(username + "\n");') | |
| pass=$(osascript -e 'display dialog "Enter password:" default answer "" giving up after 60 with text buttons {"Authenticate"} default button 1 with hidden answer' -e 'return text returned of result') | |
| attempts=1 | |
| until dscl . authonly "$user" "$pass" &>/dev/null ; do | |
| # lines 9 and 10 are only necessary if you wish to display no. of attempts remaining before failure | |
| attemptsRemaining=$(( 4 - attempts )) | |
| [[ $attemptsRemaining -eq 1 ]] && s= || s=s |
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
| ## REMOVE FIRST CHARACTER FROM STRING | |
| sed '/^.//' | |
| == Example == | |
| $ echo "foo" | sed 's/^.//' | |
| oo | |
| ____________________________________________________________________ |
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
| #!/usr/bin/env bash | |
| # stop print services | |
| launchctl stop org.cups.cupsd | |
| # back up existing configs | |
| mv /Library/Printers/InstalledPrinters.plist /Library/Printers/InstalledPrinters.plist.bak | |
| mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.bak | |
| mv /etc/cups/printers.conf /etc/cups/printers.conf.bak |
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
| parse_array() { | |
| FS=':' | |
| key=(); val=() | |
| for (( i=0 ; i < $(eval echo \${#$1[@]}) ; i++ )); do | |
| key+=( "$(eval echo \${$1[$i]} | awk -F${FS} '{print $1}')" ) | |
| val+=( "$(eval echo \${$1[$i]} | awk -F${FS} '{print $2}')" ) | |
| done | |
| } | |
| # Assuming script contains myarray=( "key1:value1" "key2:value2" ) | |
| parse_array myarray |
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
| getUserInput() | |
| { | |
| launchctl asuser $(stat -f %u /dev/console) osascript <<-APPLESCRIPT | |
| tell app "System Events" | |
| text returned of (display dialog "$1" default answer "" buttons {"OK"} default button 1) | |
| end tell | |
| APPLESCRIPT | |
| } | |
| var=$(getUserInput "type string:") |
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
| #!/bin/bash | |
| # geoff repoli | |
| # customize this variable with relatively unique + identifiable string that matches the process(es) | |
| # you want to terminate. not case-sensitive. for example: | |
| # for all microsoft applications + background services: application="microsoft" | |
| # for microsoft outlook: application="outlook" OR application="microsoft outlook" | |
| application="your string goes here" | |
| # get pids of any running microsoft processes |
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
| find /Applications -name *.app -maxdepth 2 -exec \ | |
| bash -c '[[ ! $(defaults read "{}"/Contents/Info.plist CFBundleIdentifier) =~ "com.apple" ]] \ | |
| && echo "$(basename "{}" | sed 's/.app.*//')-$(defaults read "{}"/Contents/Info.plist CFBundleShortVersionString)"' \; |
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
| yourcommand && history -d $((HISTCMD-1)) | |
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
| @echo off | |
| setlocal enableextensions | |
| for /F "usebackq" %%x in (`hostname`) do ( | |
| set COMPUTERNAME=%%x | |
| ) | |
| msiexec /i <Path>\AppleApplicationSupport.msi /q /norestart && | |
| msiexec /i <Path>\AppleApplicationSupport64.msi /q /norestart && | |
| msiexec /i <Path>\AppleMobileDeviceSupport6464.msi /q /norestart && |
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
| set subShell1 to "(your_command1)" | |
| set subShell2 to "(your_command2)" | |
| set yourScript to subShell1 & " & " & subShell2 | |
| do shell script yourScript |