From 7d9567071750a5d87564d1ba884690306466d516 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 24 Apr 2014 22:44:56 -0700 Subject: [PATCH] Add function to set hostname on osx. --- dotfiles/lib/shellrc/functions.sh | 9 +++++++++ resources/osx.sh | 5 +---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dotfiles/lib/shellrc/functions.sh b/dotfiles/lib/shellrc/functions.sh index afc12828..d9ecbe87 100644 --- a/dotfiles/lib/shellrc/functions.sh +++ b/dotfiles/lib/shellrc/functions.sh @@ -166,3 +166,12 @@ function git_reset_author() { local filter_branch_command="$should_update_command"' && '"$update_command"' || test true' git filter-branch -f --env-filter $filter_branch_command -- --all } + +function set_osx_hostname() { + local new_hostname="$1" + test -z new_hostname && new_hostname="IvansMac" + sudo scutil --set ComputerName $new_hostname + sudo scutil --set HostName $new_hostname + sudo scutil --set LocalHostName $new_hostname + sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $new_hostname +} diff --git a/resources/osx.sh b/resources/osx.sh index 202baac9..2c5d6a8f 100755 --- a/resources/osx.sh +++ b/resources/osx.sh @@ -11,10 +11,7 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & ############################################################################### # Set computer name (as done via System Preferences → Sharing) -sudo scutil --set ComputerName "IvansMac" -sudo scutil --set HostName "IvanMalison" -sudo scutil --set LocalHostName "IvanMalison" -sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "IvanMalison" +set_osx_hostname # Menu bar: disable transparency defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false