From 92502d24499cfa82f49a8175caa67fb2de49b896 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 9 May 2017 10:52:13 +0100 Subject: [PATCH] Move osx specific shell setup to osx.sh --- shell/_main.sh | 5 +++++ shell/aliases.sh | 37 +++++-------------------------------- shell/osx.sh | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 shell/osx.sh diff --git a/shell/_main.sh b/shell/_main.sh index 0658c21..148a70c 100755 --- a/shell/_main.sh +++ b/shell/_main.sh @@ -29,6 +29,11 @@ source "$DOTSHELL/nix.sh" # Aliases source "$DOTSHELL/aliases.sh" +# OSX specific +if [[ "$(uname)" == "Darwin" ]]; then + source "$DOTSHELL/osx.sh" +fi + # Utils source "$DOTSHELL/emacs.sh" source "$DOTSHELL/git.sh" diff --git a/shell/aliases.sh b/shell/aliases.sh index 88b31db..cb71f6a 100644 --- a/shell/aliases.sh +++ b/shell/aliases.sh @@ -41,34 +41,20 @@ alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\ alias fku="fuck you" alias fucking="sudo" -# Fix wifi issues on OS X 10.10.x Yosemite. -# - from: https://medium.com/@mariociabarra/wifried-ios-8-wifi-performance-issues-3029a164ce94 -alias fix_wifi="sudo ifconfig awdl0 down" -alias unfix_wifi="sudo ifconfig awdl0 up" - -# Disable the system built-in cmd+ctrl+d global hotkey to lookup word in -# dictionary on OS X. Must reboot after running. -# - from: ://apple.stackexchange.com/a/114269 -osx-disable-lookup-word-hotkey() { - defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 \ - 'enabled' - echo "Command-Control-D hotkey disabled. Please reboot to take effect." -} - # Improved myip alias. Echoed to avoid strange character at end in ZSH. -function myip { +myip() { echo "$(curl -s whatismyip.akamai.com)" } # appends your key to a server's authorized keys file -function authme { +authme() { ssh "$1" 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' \ < ~/.ssh/id_rsa.pub } # ssh commands related to old SSH keys alias ssho="ssh -i ~/.ssh/old-id_rsa" -function authmeo { +authmeo() { ssh -i ~/.ssh/old-id_rsa "$1" \ 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' \ < ~/.ssh/id_rsa.pub @@ -76,7 +62,7 @@ function authmeo { # Make and cd into directory # - from: http://alias.sh/make-and-cd-directory -function mcd() { +mcd() { mkdir -p "$1" && cd "$1"; } @@ -87,7 +73,7 @@ pman () { # Extract most common archives with single command. # - from: http://alias.sh/extract-most-know-archives-one-command -function extract () { +extract() { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; @@ -111,16 +97,3 @@ function extract () { fi } alias ext=extract - - -# Show hidden files in Finder. -function show_files { - defaults write com.apple.finder AppleShowAllFiles YES - killall Finder "/System/Library/CoreServices/Finder.app" -} - -# Don't show hidden files in Finder. -function hide_files { - defaults write com.apple.finder AppleShowAllFiles NO - killall Finder "/System/Library/CoreServices/Finder.app" -} diff --git a/shell/osx.sh b/shell/osx.sh new file mode 100644 index 0000000..7942017 --- /dev/null +++ b/shell/osx.sh @@ -0,0 +1,39 @@ +# +# OSX Related +# + +# Fix wifi issues on OS X 10.10.x Yosemite. +# - from: https://medium.com/@mariociabarra/wifried-ios-8-wifi-performance-issues-3029a164ce94 +alias fix_wifi="sudo ifconfig awdl0 down" +alias unfix_wifi="sudo ifconfig awdl0 up" + +# Disable the system built-in cmd+ctrl+d global hotkey to lookup word in +# dictionary on OS X. Must reboot after running. +# - from: ://apple.stackexchange.com/a/114269 +osx-disable-lookup-word-hotkey() { + defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 \ + 'enabled' + echo "Command-Control-D hotkey disabled. Please reboot to take effect." +} + +# Show hidden files in Finder. +show_files() { + defaults write com.apple.finder AppleShowAllFiles YES + killall Finder "/System/Library/CoreServices/Finder.app" +} + +# Don't show hidden files in Finder. +hide_files() { + defaults write com.apple.finder AppleShowAllFiles NO + killall Finder "/System/Library/CoreServices/Finder.app" +} + +# Power management +alias pm-hibernate="sudo pmset -a hibernatemode 25" +alias pm-safesleep="sudo pmset -a hibernatemode 3" +alias pm-sleep="sudo pmset -a hibernatemode 0" + +hibernate() { + sudo pmset -a hibernatemode 25 + sudo pmset sleepnow +}