Add function to set hostname on osx.

This commit is contained in:
Ivan Malison 2014-04-24 22:44:56 -07:00
parent a0ade716a2
commit 7d95670717
2 changed files with 10 additions and 4 deletions

View File

@ -166,3 +166,12 @@ function git_reset_author() {
local filter_branch_command="$should_update_command"' && '"$update_command"' || test true' local filter_branch_command="$should_update_command"' && '"$update_command"' || test true'
git filter-branch -f --env-filter $filter_branch_command -- --all 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
}

View File

@ -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) # Set computer name (as done via System Preferences → Sharing)
sudo scutil --set ComputerName "IvansMac" set_osx_hostname
sudo scutil --set HostName "IvanMalison"
sudo scutil --set LocalHostName "IvanMalison"
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "IvanMalison"
# Menu bar: disable transparency # Menu bar: disable transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false