Hari Sekhon 4 years ago
commit a3fbd5e930

@ -27,6 +27,9 @@ bash_tools="${bash_tools:-$(dirname "${BASH_SOURCE[0]}")/..}"
isMac || return
alias osash="osascript -i"
alias osashell=osash
date(){
gdate "$@"
}

@ -316,7 +316,7 @@ nmap <silent> ;s :,!sqlcase.pl<CR>
"nmap ;; :! . ~/.bashrc; gitu "%"<CR>
nmap ;; :w<CR> :! bash -ic 'gitu "%"'<CR>
nmap ;g :w<CR> :! bash -ic 'cd $(dirname "%") && st'<CR>
nmap ;G :w<CR> :! bash -ic 'cd $(dirname "%") && git log -p'<CR>
nmap ;G :w<CR> :! bash -ic 'cd $(dirname "%") && git log -p "%"'<CR>
nmap ;. :w<CR> :! bash -ic 'cd $(dirname "%") && pull'<CR>
nmap ;[ :w<CR> :! bash -ic 'cd $(dirname "%") && push'<CR>
nmap <silent> ;u :w<CR> :!urlview "%"<CR>

@ -0,0 +1,27 @@
#!/usr/bin/env osascript
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2020-06-13 20:43:57 +0100 (Sat, 13 Jun 2020)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
# Gets the coordinates of the mouse cursor
#
# other options:
#
# Cmd-Shift-4 - to take a select area screenshot displays the coordates, then press Esc to cancel
#
# MouseTools -location
tell application "System Events"
# doesn't work due to mouse not being defined
set mousePosition to position of the mouse
end tell

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
MouseTools -location

@ -0,0 +1,48 @@
#!/usr/bin/env osascript
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2020-06-13 20:47:12 +0100 (Sat, 13 Jun 2020)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
# Click N times at coordinates x,y
#
# waits 5 seconds before starting
#
# easier to just use 'MouseTools -leftClick' command line, see adjacent mouse_clicks.sh
# Incomplete, doesn't seem to work, use adjacent mouse_clicks.sh instead which works nicely
set N to 10
# see adjacent get_mouse_coordinates.scpt for how to get the mouse coordinates
set x to 2455
set y to 1273
do shell script "echo waiting 5 secs before starting clicking"
delay 5
# repeat N times
# want loop iterator variable to print the click we're on
set i to 0
repeat while i < N
tell application "System Events"
click at {x,y}
end tell
#do shell script "echo click " & i
#copy "click " & i to stdout
set i to i + 1
delay 1
end repeat
# looks like last thing printed overwrites all previous output :-/
copy "DONE" to stdout

@ -0,0 +1,50 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2020-06-14 17:16:31 +0100 (Sun, 14 Jun 2020)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1090
. "$srcdir/../lib/utils.sh"
usage(){
echo "
Performs N mouse clicks at the current mouse coordinates location, 1 second apart to automate tedious UI actions
Starts clicking after 5 seconds to give time to alt-tab back to your UI application and position the cursor
${0##*/} <num>"
exit 3
}
if [ $# != 1 ]; then
usage
fi
if ! [[ "$1" =~ ^[[:digit:]]+$ ]]; then
usage
fi
num="$1"
sleep 5
# shellcheck disable=SC2086
for i in $(seq "$num"); do
timestamp "click $i"
MouseTools -leftClick
sleep 1
done

@ -46,6 +46,8 @@ for script in $scripts; do
run_fail='run(_[a-z]+[[:digit:]]* "?[[:digit:][:space:]]+"?|_conn_refused|_usage|_404|_timeout)?'
# docker-compose or docker exec or docker run
docker_regex='docker(-compose|[[:space:]]+(exec|run))'
# want $bin in regex
# shellcheck disable=SC2016
suspect_lines="$(grep -En '^[[:space:]]*run(_.+)?[[:space:]]+' "$script" |
grep -Ev -e "[[:space:]]*${run_fail}[[:space:]](.*[[:space:]])?(./|(\\\$perl|eval|$docker_regex)[[:space:]])" \
-e '[[:space:]]*run_test_versions' \

@ -63,11 +63,16 @@ else
chmod +x ~/bin/ecs-cli
fi
if grep Alpine /etc/os-release &>/dev/null; then
if grep -q Alpine /etc/os-release 2>/dev/null; then
echo "Skipping SAM CLI install on Alpine as Homebrew installer is broken on Alpine, see https://github.com/Homebrew/homebrew-core/issues/49813"
exit 0
fi
if grep -q 'CentOS release [1-6][\.[:space:]]' /etc/system-release 2>/dev/null; then
echo "Skipping SAM CLI install on RHEL/CentOS < 7 as Homebrew installer no longer supports it, see https://github.com/Homebrew/brew/issues/7583#issuecomment-640379742"
exit 0
fi
# installs on Linux too as it is the AWS recommended method to install SAM CLI
"$srcdir/install_homebrew.sh"
echo

@ -0,0 +1,54 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2020-06-14 17:01:04 +0100 (Sun, 14 Jun 2020)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
# Installs CliClick on Mac OS X
#
# https://github.com/BlueM/cliclick
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
#srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VERSION="4.0.1"
if [ "$(uname -s)" != Darwin ]; then
echo "Operating System is not Mac, cannot install MouseTools which is for Mac, aborting..."
exit 0
fi
if type -P cliclick &>/dev/null; then
echo "CliClick already installed"
exit 0
fi
cd /tmp
wget -O "cliclick-$VERSION.zip" "https://github.com/BlueM/cliclick/archive/$VERSION.zip"
unzip -o "cliclick-$VERSION.zip"
cd "cliclick-$VERSION"
echo
echo "Building cliclick"
make
echo
mv -iv cliclick ~/bin
echo
rm -fr "cliclick-$VERSION" "cliclick-$VERSION.zip"
echo "cliclick is now available at ~/bin - ensure that location is in $PATH"

@ -11,6 +11,10 @@
#
# Install Homebrew on Mac OS X
#
# doesn't install on CentOS 6 any more
#
# https://github.com/Homebrew/brew/issues/7583#issuecomment-640379742
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x

@ -0,0 +1,45 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2020-06-14 15:47:33 +0100 (Sun, 14 Jun 2020)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
# Installs MouseTools on Mac OS X
#
# http://www.hamsoftengineering.com/codeSharing/MouseTools/MouseTools.html
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
#srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ "$(uname -s)" != Darwin ]; then
echo "Operating System is not Mac, cannot install MouseTools which is for Mac, aborting..."
exit 0
fi
if type -P MouseTools &>/dev/null; then
echo "MouseTools already installed"
exit 0
fi
cd /tmp
wget -O MouseTools.zip http://www.hamsoftengineering.com/assets/MouseTools.zip
unzip -o MouseTools.zip
mv -iv MouseTools ~/bin
rm MouseTools.zip
echo
echo "MouseTools is now available at ~/bin - ensure that location is in $PATH"

@ -0,0 +1,179 @@
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2020-03-01 21:01:50 +0000 (Sun, 01 Mar 2020)
#
# https://github.com/harisekhon/bash-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
# require password immediately after sleep / screen saver
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# auto-restart after a system freeze
#sudo systemsetup -setrestartfreeze on
# Check for software updates daily, not just once per week
#defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
# Disable local Time Machine snapshots
#sudo tmutil disablelocal
# Trackpad: enable tap to click for this user and for the login screen
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# Enable “natural” (Lion-style) scrolling
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool true
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
# Avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Automatically open a new Finder window when a volume is mounted
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true
# ============================================================================ #
# Finder:
# set Downloads as the default location for new Finder windows
defaults write com.apple.finder NewWindowTarget -string "PfDe"
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Downloads/"
# allow copying from Quick Look preview
defaults write com.apple.finder QLEnableTextSelection -bool true
# show the ~/Library folder
#chflags nohidden ~/Library
# Empty Trash securely by default
defaults write com.apple.finder EmptyTrashSecurely -bool true
# disable the warning before emptying the Trash
#defaults write com.apple.finder WarnOnEmptyTrash -bool false
# show hidden files by default
defaults write com.apple.finder AppleShowAllFiles -bool true
# show all filename extensions
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# show path bar
defaults write com.apple.finder ShowPathbar -bool true
# display full POSIX path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Show icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
#killall Finder
# ============================================================================ #
# Preview:
# set to false to not re-open previous documents from last Preview session
defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool true
#killall Preview
# ============================================================================ #
# Screenshots:
# save screenshots to Desktop
defaults write com.apple.screencapture location -string "${HOME}/Desktop"
# save in PNG format (default, other options: BMP, GIF, JPG, PDF, TIFF)
defaults write com.apple.screencapture type -string "png"
#defaults write com.apple.screencapture type JPG
# default screenshot file name
# defaults write com.apple.screencapture name "myScreenShot"
# disable drop shadows in screenshots
defaults write com.apple.screencapture disable-shadow -bool true
# killall SystemUIServer
# ============================================================================ #
# Dock:
# hide non-active apps
#defaults write com.apple.dock static-only -bool TRUE
# stop apps saving to iCloud by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# pop-up instantly
defaults write com.apple.dock autohide-delay -float 0 # secs
# disappear instantly
defaults write com.apple.dock autohide-time-modifier -float 0
# revert to default delay
#defaults delete com.apple.dock autohide-delay
#defaults write com.apple.dock autohide-time-modifier
# enable Dashboard with widgets
#defaults write com.apple.dashboard mcx-disabled -boolean false
#killall Dock
# ============================================================================ #
# Enable AirDrop over Ethernet and on unsupported Macs running Lion
#defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
# Change indexing order and disable some search results
#defaults write com.apple.spotlight orderedItems -array \
# '{"enabled" = 1;"name" = "APPLICATIONS";}' \
# '{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \
# '{"enabled" = 0;"name" = "DIRECTORIES";}' \
# '{"enabled" = 0;"name" = "PDF";}' \
# '{"enabled" = 0;"name" = "FONTS";}' \
# '{"enabled" = 0;"name" = "DOCUMENTS";}' \
# '{"enabled" = 0;"name" = "MESSAGES";}' \
# '{"enabled" = 0;"name" = "CONTACT";}' \
# '{"enabled" = 0;"name" = "EVENT_TODO";}' \
# '{"enabled" = 0;"name" = "IMAGES";}' \
# '{"enabled" = 0;"name" = "BOOKMARKS";}' \
# '{"enabled" = 0;"name" = "MUSIC";}' \
# '{"enabled" = 0;"name" = "MOVIES";}' \
# '{"enabled" = 0;"name" = "PRESENTATIONS";}' \
# '{"enabled" = 0;"name" = "SPREADSHEETS";}' \
# '{"enabled" = 0;"name" = "SOURCE";}' \
# '{"enabled" = 1;"name" = "MENU_DEFINITION";}' \
# '{"enabled" = 0;"name" = "MENU_OTHER";}' \
# '{"enabled" = 0;"name" = "MENU_CONVERSION";}' \
# '{"enabled" = 1;"name" = "MENU_EXPRESSION";}' \
# '{"enabled" = 0;"name" = "MENU_WEBSEARCH";}' \
# '{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}'
echo "Some settings won't take effect until you restart Finder. When you're ready, run:
killall Finder
killall Dock
killall SystemUIServer
"
Loading…
Cancel
Save