From ae2db75f3e5e59290e8838508cb7566d82b9cd8a Mon Sep 17 00:00:00 2001 From: Chris Blackburn Date: Sat, 21 Jan 2012 19:12:38 -0600 Subject: [PATCH 1/4] Added dot-env plugin Dot-env is a cross-platform, cascading Zsh environment system for those who work on different hardware and OS environments. See: https://github.com/midwire/.env --- plugins/dot-env/dot-env.plugin.zsh | 53 ++++ plugins/dot-env/global/alias/chmod.sh | 9 + plugins/dot-env/global/alias/git.sh | 12 + plugins/dot-env/global/alias/ls.sh | 14 + plugins/dot-env/global/alias/misc.sh | 5 + plugins/dot-env/global/alias/navigation.sh | 8 + plugins/dot-env/global/alias/rails.sh | 20 ++ plugins/dot-env/global/global_alias.sh | 7 + plugins/dot-env/global/global_env.sh | 27 ++ plugins/dot-env/global/global_functions.sh | 86 ++++++ plugins/dot-env/global/global_path.sh | 31 +++ plugins/dot-env/os/Darwin/alias.sh | 2 + plugins/dot-env/os/Darwin/editor.sh | 22 ++ plugins/dot-env/os/Darwin/functions.sh | 288 +++++++++++++++++++++ plugins/dot-env/os/Darwin/path.sh | 1 + plugins/dot-env/os/Linux/alias.sh | 22 ++ plugins/dot-env/os/Linux/env.sh | 5 + plugins/dot-env/os/Linux/functions.sh | 0 plugins/dot-env/os/SunOS/alias.sh | 4 + plugins/dot-env/os/SunOS/functions.sh | 13 + 20 files changed, 629 insertions(+) create mode 100644 plugins/dot-env/dot-env.plugin.zsh create mode 100644 plugins/dot-env/global/alias/chmod.sh create mode 100644 plugins/dot-env/global/alias/git.sh create mode 100644 plugins/dot-env/global/alias/ls.sh create mode 100644 plugins/dot-env/global/alias/misc.sh create mode 100644 plugins/dot-env/global/alias/navigation.sh create mode 100644 plugins/dot-env/global/alias/rails.sh create mode 100644 plugins/dot-env/global/global_alias.sh create mode 100644 plugins/dot-env/global/global_env.sh create mode 100644 plugins/dot-env/global/global_functions.sh create mode 100644 plugins/dot-env/global/global_path.sh create mode 100644 plugins/dot-env/os/Darwin/alias.sh create mode 100644 plugins/dot-env/os/Darwin/editor.sh create mode 100644 plugins/dot-env/os/Darwin/functions.sh create mode 100644 plugins/dot-env/os/Darwin/path.sh create mode 100644 plugins/dot-env/os/Linux/alias.sh create mode 100644 plugins/dot-env/os/Linux/env.sh create mode 100644 plugins/dot-env/os/Linux/functions.sh create mode 100644 plugins/dot-env/os/SunOS/alias.sh create mode 100644 plugins/dot-env/os/SunOS/functions.sh diff --git a/plugins/dot-env/dot-env.plugin.zsh b/plugins/dot-env/dot-env.plugin.zsh new file mode 100644 index 000000000..cd887ef14 --- /dev/null +++ b/plugins/dot-env/dot-env.plugin.zsh @@ -0,0 +1,53 @@ +# Skip all this for non-interactive shells +[[ -z "$PS1" ]] && return + +export DOT_ENV_PATH="$( cd "$( dirname "${0}" )" && pwd )" + +OS=`uname` +if [[ $OS == 'Darwin' ]]; then + x=1 +elif [[ $OS == 'SunOS' ]]; then + x=1 +elif [[ $OS == 'Linux' ]]; then + x=1 +else + echo "Sorry, no portable environment support for your platform: '$OS'" + exit 1 +fi +OS_DIR=$DOT_ENV_PATH/os/$OS + +# Make sure globals are sourced before OS specifics +if [[ "$SHLVL" == "1" ]]; then + echo "Sourcing Global Environment" +fi +for i in $DOT_ENV_PATH/global/global_*.sh ; do + if [ -r "$i" ]; then + . $i + fi +done + +# Now source OS specifics +if [[ "$SHLVL" == "1" ]]; then + echo "Sourcing $OS Environment" +fi +for i in $OS_DIR/*.sh ; do + if [ -r "$i" ]; then + . $i + fi +done + +# Source Host specifics if there are any for the current host +if [[ ! -z "$HOST" ]]; then + HOST_DIR=$DOT_ENV_PATH/host/`hostname` + if [[ "$SHLVL" == "1" ]]; then + echo "Sourcing '$HOST' Environment" + fi + for i in $HOST_DIR/*.sh ; do + if [ -r "$i" ]; then + . $i + fi + done +fi + +unset i + diff --git a/plugins/dot-env/global/alias/chmod.sh b/plugins/dot-env/global/alias/chmod.sh new file mode 100644 index 000000000..14605c753 --- /dev/null +++ b/plugins/dot-env/global/alias/chmod.sh @@ -0,0 +1,9 @@ +# Alias chmod commands +alias 000='chmod 000' +alias 600='chmod 600' +alias 644='chmod 644' +alias 755='chmod 755' +alias mgid='chmod g+s' +alias mx='chmod a+x' +alias rgid='chmod g-s' +alias rx='chmod a-x' diff --git a/plugins/dot-env/global/alias/git.sh b/plugins/dot-env/global/alias/git.sh new file mode 100644 index 000000000..533014aa2 --- /dev/null +++ b/plugins/dot-env/global/alias/git.sh @@ -0,0 +1,12 @@ +# Git aliases +alias add='git add' +alias branch='git branch' +alias co='git checkout' +alias commit='git commit' +alias fetch='git fetch' +alias gadd='git add .' +alias gt='gittower' +alias merge='git merge' +alias pull='git pull' +alias push='git push' +alias st='git status' diff --git a/plugins/dot-env/global/alias/ls.sh b/plugins/dot-env/global/alias/ls.sh new file mode 100644 index 000000000..d6fd514ad --- /dev/null +++ b/plugins/dot-env/global/alias/ls.sh @@ -0,0 +1,14 @@ +# Directory Listing aliases +alias dir='ls -hFx' +alias l.='ls -d .* --color=tty' +alias l='ls -lathF' +alias L='ls -latrhF' +alias la='ls -Al' # show hidden files +alias lc='ls -lcr' # sort by change time +alias lk='ls -lSr' # sort by size +alias ll='ls -lFh' +alias lm='ls -al |more' # pipe through 'more' +alias lo='ls -laSFh' +alias lr='ls -lR' # recursive ls +alias lt='ls -ltr' # sort by date +alias lu='ls -lur' # sort by access time diff --git a/plugins/dot-env/global/alias/misc.sh b/plugins/dot-env/global/alias/misc.sh new file mode 100644 index 000000000..07e8e36a6 --- /dev/null +++ b/plugins/dot-env/global/alias/misc.sh @@ -0,0 +1,5 @@ +# Miscellaneous aliases +alias c='clear' +alias cls='clear' +alias h='history' +alias path='echo $PATH' diff --git a/plugins/dot-env/global/alias/navigation.sh b/plugins/dot-env/global/alias/navigation.sh new file mode 100644 index 000000000..2bda77909 --- /dev/null +++ b/plugins/dot-env/global/alias/navigation.sh @@ -0,0 +1,8 @@ +# ChDir aliases +alias ..='cd ..' +alias ...='cd ../..' +alias 1..='cd ..' +alias 2..='cd ../..' +alias 3..='cd ../../..' +alias 4..='cd ../../../..' +alias 5..='cd ../../../../..' diff --git a/plugins/dot-env/global/alias/rails.sh b/plugins/dot-env/global/alias/rails.sh new file mode 100644 index 000000000..9650533a5 --- /dev/null +++ b/plugins/dot-env/global/alias/rails.sh @@ -0,0 +1,20 @@ +# Rails & Development Aliases +alias a='autotest -rails' +alias b="bundle" +alias be="bundle exec" +alias bi="bundle install --path vendor" +alias bil="bi --local" +alias binit="bi && bundle package && echo 'vendor/ruby' >> .gitignore" +alias bu="bundle update" +alias p='pry' +alias rc='rails c' +alias rd='rails destroy' +alias re='echo $RAILS_ENV' +alias rg='rails g' +alias rp='rails plugin' +alias rs='rails s' +alias sc='./script/console' +alias sd='./script/destroy' +alias sg='./script/generate' +alias sp='./script/plugin' +alias ss='./script/server' diff --git a/plugins/dot-env/global/global_alias.sh b/plugins/dot-env/global/global_alias.sh new file mode 100644 index 000000000..b6a20dfc9 --- /dev/null +++ b/plugins/dot-env/global/global_alias.sh @@ -0,0 +1,7 @@ +# Now source global aliases +for i in $DOT_ENV_PATH/global/alias/*.sh ; do + if [ -r "$i" ]; then + . $i + fi +done +unset i diff --git a/plugins/dot-env/global/global_env.sh b/plugins/dot-env/global/global_env.sh new file mode 100644 index 000000000..d15792eb5 --- /dev/null +++ b/plugins/dot-env/global/global_env.sh @@ -0,0 +1,27 @@ +# Some of this is taken from matt.blissett.me.uk +# Thanks Matt! + +# Command History +export HISTIGNORE="&:ls:[bf]g:exit:reset:clear:cd:cd ..:cd.." +export HISTSIZE=25000 +setopt INC_APPEND_HISTORY +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_IGNORE_SPACE +setopt HIST_REDUCE_BLANKS +setopt HIST_VERIFY + +# Say how long a command took, if it took more than 30 seconds +export REPORTTIME=30 + +# Prompts for confirmation after 'rm *' etc +# Helps avoid mistakes like 'rm * o' when 'rm *.o' was intended +setopt RM_STAR_WAIT + +# Background processes aren't killed on exit of shell +setopt AUTO_CONTINUE + +# Watch other user login/out +watch=notme +export LOGCHECK=60 + +export LSCOLORS="gxfxcxdxbxegedabagacad" diff --git a/plugins/dot-env/global/global_functions.sh b/plugins/dot-env/global/global_functions.sh new file mode 100644 index 000000000..5baae3549 --- /dev/null +++ b/plugins/dot-env/global/global_functions.sh @@ -0,0 +1,86 @@ +# Add your public SSH key to a remote host +function add_ssh_key_to_host { + if [[ $# -lt 1 ]]; then + echo_warn "Usage: add_ssh_key_to_host [user@]HOSTNAME" + return + fi + if [[ -r ~/.ssh/id_dsa.pub ]]; then + cat ~/.ssh/id_dsa.pub | ssh $1 "cat >> .ssh/authorized_keys" + elif [[ -r ~/.ssh/id_rsa.pub ]]; then + cat ~/.ssh/id_rsa.pub | ssh $1 "cat >> .ssh/authorized_keys" + fi +} + +# Propagate your entire environment system to a remote host +function propagate_env_to_host { + if [[ $# -lt 1 ]]; then + echo_warn "Usage: propagate_env_to_host [user@]HOSTNAME" + return + fi + + host=$1 + shift 1 + ENVFILE=$HOME/env.tar.gz + PWD=`pwd` + cd $HOME + echo_info "Compressing local environment..." + tar cfvz $ENVFILE .env/ &> /dev/null + echo_info "Copying environment to $host..." + scp $ENVFILE $host: + if [[ $? != 0 ]]; then echo "Copy failed!"; return; fi + echo_info "Installing environment on $host..." + ssh $host "rm -rf ~/.env/ && gunzip < env.tar.gz |tar xfv -" &> /dev/null + echo_warn "Don't forget to add this your .bashrc file:" + echo_warn 'if [[ -n "$PS1" ]]; then' + echo_warn ' [[ -r $HOME/.env/source.sh ]] && . $HOME/.env/source.sh' + echo_warn 'fi' + cd $PWD +} + +# Configure environment settings for your local machine. +function configthis.env { + DIR="$DOT_ENV_PATH/host/$HOSTNAME" + mkdir -p "$DIR" + touch "$DIR/env.sh" + touch "$DIR/functions.sh" + if [[ ! -f "$DIR/alias.sh" ]]; then + echo "# Add your specific aliases here:\n# Example: alias home='cd \$HOME' " >> "$DIR/alias.sh" + fi + if [[ ! -f "$DIR/prompt.sh" ]]; then + echo "# Define your prompt here:\n# Example: PS1=\$BLUE\u@\H\$NO_COLOR " >> "$DIR/prompt.sh" + fi + if [[ ! -f "$DIR/path.sh" ]]; then + echo "# Add paths like this:\n# pathmunge \"/Developer/usr/bin\"" >> "$DIR/path.sh" + fi + cd "$DIR" + echo_info "Edit these files to customize your local environment." + ls -1AtF +} + +# Configure environment settings for a specified HOSTNAME +function confighost.env { + if [[ $# -lt 1 ]]; then + echo_warn "Usage: confighost.env HOSTNAME" + return + fi + host=$1 + shift 1 + DIR="$DOT_ENV_PATH/host/$host" + mkdir -p "$DIR" + touch "$DIR/env.sh" + touch "$DIR/functions.sh" + if [[ ! -f "$DIR/alias.sh" ]]; then + echo "# Add your host specific aliases here:\n# Example: alias home='cd \$HOME' " >> "$DIR/alias.sh" + fi + if [[ ! -f "$DIR/prompt.sh" ]]; then + echo "# Define your prompt here:\n# Example: PS1=\$BLUE\u@\H\$NO_COLOR " >> "$DIR/prompt.sh" + fi + if [[ ! -f "$DIR/path.sh" ]]; then + echo "# Add paths like this:\n# pathmunge \"/Developer/usr/bin\"" >> "$DIR/path.sh" + fi + cd "$DIR" + echo_info "Edit these files to customize your [$host] environment." + echo_info "When you are finished run 'propagate_env_to_host $host'." + ls -1AtF +} + diff --git a/plugins/dot-env/global/global_path.sh b/plugins/dot-env/global/global_path.sh new file mode 100644 index 000000000..1b49b79ec --- /dev/null +++ b/plugins/dot-env/global/global_path.sh @@ -0,0 +1,31 @@ +paths="${DOT_ENV_PATH}/bin +/sbin +/bin +/usr/X11/bin +/usr/local/bin +/usr/sbin +/usr/bin" + +EGREP=`which egrep` +function pathmunge () { + if ! echo $PATH | $EGREP "(^|:)$1($|:)" > /dev/null ; then + if [ -d "$1" ]; then + if [ "$2" = "before" ] ; then + PATH="$1:$PATH" + else + PATH="$PATH:$1" + fi + fi + fi +} + +for p in $paths; do + pathmunge $p +done + +# Prepend path with $HOME/bin +pathmunge "$HOME/bin" before + +PATH=`echo $PATH | sed -e 's/^\://' -e 's/\:\:/:/g'` +unset paths +export PATH diff --git a/plugins/dot-env/os/Darwin/alias.sh b/plugins/dot-env/os/Darwin/alias.sh new file mode 100644 index 000000000..e709fc582 --- /dev/null +++ b/plugins/dot-env/os/Darwin/alias.sh @@ -0,0 +1,2 @@ +# Process Find Aliases +alias pfn='ps -e -o euser,pid,args|grep' diff --git a/plugins/dot-env/os/Darwin/editor.sh b/plugins/dot-env/os/Darwin/editor.sh new file mode 100644 index 000000000..0f6e99ea8 --- /dev/null +++ b/plugins/dot-env/os/Darwin/editor.sh @@ -0,0 +1,22 @@ +# Textmate Editing and Sourcing aliases +# export EDITOR="$HOME/bin/mate" + +# Textmate 2 Editor +# export EDITOR="$HOME/bin/mate2" + +# Sublime Text 2 Editor +export EDITOR="$HOME/bin/subl" + +alias e="$EDITOR ." +alias ea="$EDITOR $DOT_ENV_PATH/host/$HOSTNAME/alias.sh" +alias eas=". $DOT_ENV_PATH/host/$HOSTNAME/alias.sh" +alias eb="$EDITOR $HOME/bin" +alias ee="$EDITOR $DOT_ENV_PATH $HOME/.bashrc" +alias ees=". $DOT_ENV_PATH/source.sh" +alias ef="$EDITOR $DOT_ENV_PATH/host/$HOSTNAME/functions.sh" +alias efs=". $DOT_ENV_PATH/host/$HOSTNAME/functions.sh" +alias eh="$EDITOR $HOME/.ssh" +alias ep="$EDITOR $DOT_ENV_PATH/host/$HOSTNAME/path.sh" +alias eps=". $DOT_ENV_PATH/host/$HOSTNAME/path.sh" +alias m="$EDITOR" +alias vi="$EDITOR" diff --git a/plugins/dot-env/os/Darwin/functions.sh b/plugins/dot-env/os/Darwin/functions.sh new file mode 100644 index 000000000..d7ba48253 --- /dev/null +++ b/plugins/dot-env/os/Darwin/functions.sh @@ -0,0 +1,288 @@ +# cdf: cd's to frontmost window of Finder +cdf () { + currFolderPath=$( /usr/bin/osascript <<"EOT" + tell application "Finder" + try + set currFolder to (folder of the front window as alias) + on error + set currFolder to (path to desktop folder as alias) + end try + POSIX path of currFolder + end tell +EOT + ) + echo "cd to \"$currFolderPath\"" + cd "$currFolderPath" +} + +# File Finders +# ff: to find a file under the current directory +ff () { /usr/bin/find . -name "$@" ; } +# ffs: to find a file whose name starts with a given string +ffs () { /usr/bin/find . -name "$@"'*' ; } +# ffe: to find a file whose name ends with a given string +ffe () { /usr/bin/find . -name '*'"$@" ; } + +# SPOTLIGHT +# locatemd: to search for a file using Spotlight's metadata +function locatemd { mdfind "kMDItemDisplayName == '$@'wc"; } +# locaterecent: to search for files created since yesterday using Spotlight +# This is an illustration of using $time in a query +# See: http://developer.apple.com/documentation/Carbon/Conceptual/SpotlightQuery/index.html +function locaterecent { mdfind 'kMDItemFSCreationDate >= $time.yesterday'; } + +# list_all_apps: list all applications on the system +list_all_apps() { mdfind 'kMDItemContentTypeTree == "com.apple.application"c' ; } + +# find_larger: find files larger than a certain size (in bytes) +find_larger() { find . -type f -size +${1}c ; } + +#------------ +# Processes: +#------------ +alias pstree='/usr/local/bin/pstree -g 2 -w' + +# findPid: find out the pid of a specified process +# Note that the command name can be specified via a regex +# E.g. findPid '/d$/' finds pids of all processes with names ending in 'd' +# Without the 'sudo' it will only find processes of the current user +findPid () { sudo /usr/sbin/lsof -t -c "$@" ; } + +# to find memory hogs: +alias mem_hogs_top='top -l 1 -o rsize -n 10' +alias mem_hogs_ps='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10' + +# to find CPU hogs +alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10' + +# continual 'top' listing (every 10 seconds) showing top 15 CPU consumers +alias topforever='top -l 0 -s 10 -o cpu -n 15' + +# recommended 'top' invocation to minimize resources in thie macosxhints article +# http://www.macosxhints.com/article.php?story=20060816123853639 +# exec /usr/bin/top -R -F -s 10 -o rsize + +# diskwho: to show processes reading/writing to disk +alias diskwho='sudo iotop' + +#------------ +# Networking: +#------------ +# lsock: to display open sockets (the -P option to lsof disables port names) +alias lsock='sudo /usr/sbin/lsof -i -P' + +# airportMtu: set the MTU on Airport to be a value that makes SMTP to DSL work +# (I determined the value empirically by using 'ping -s' to the SMTP server) +alias airportMtu='sudo ifconfig en1 mtu 1364' + +# airport: Apple's command-line tool. For status info, use -I, for help use -h +# See: http://www.macosxhints.com/article.php?story=20050715001815547 +alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport' +# Note also the tool that I compiled: airport_info (in my Tools dir) + +# ip_info: to get info on DHCP server, router, DNS server, etc (for en0 or en1) +alias ip_info='ipconfig getpacket en1' + +# browse_bonjour: browse services advertised via Bonjour +# Note: need to supply a "type" argument- e.g. "_http._tcp" +# See http://www.dns-sd.org/ServiceTypes.html for more types +# Optionally supply a "domain" argument +alias browse_bonjour='dns-sd -B' + +# hostname_lookup: interactive debugging mode for lookupd (use tab-completion) +alias hostname_lookup='lookupd -d' + +# debug_http: download a web page and show info on what took time +debug_http () { /usr/bin/curl $@ -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; } + +# http_headers: get just the HTTP headers from a web page (and its redirects) +http_headers () { /usr/bin/curl -I -L $@ ; } + +# Note: 'active_net_iface' is my script that echos the active net interface +# pkt_trace: for use in the following aliases +alias pkt_trace='sudo tcpflow -i `active_net_iface` -c' + +# smtp_trace: to show all SMTP packets +alias smtp_trace='pkt_trace port smtp' + +# http_trace: to show all HTTP packets +alias http_trace='pkt_trace port 80' + +# tcp_trace: to show all TCP packets +alias tcp_trace='pkt_trace tcp' + +# udp_trace: to show all UDP packets +alias udp_trace='pkt_trace udp' + +# ip_trace: to show all IP packets +alias ip_trace='pkt_trace ip' + +# can use 'scselect' to find out current network "location" +# can use 'scutil' for other system config stuff + +# to do socket programming in bash, redirect to /dev/tcp/$host/$port +# Example: +osaClient () +{ + exec 5<> /dev/tcp/localhost/4321 + cat $1 >&5 + echo "-- end of file" >&5 + cat <&5 + exec 5>&- +} + + +#------ +# Misc: +#------ +# epochtime: report number of seconds since the Epoch +alias epochtime='date +%s' + +# screensaverdesktop: run a screensaver on the Desktop +alias screensaverdesktop='/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background' + +# consoleapp: launch the Console app from Terminal +alias consoleapp='/Applications/Utilities/Console.app/Contents/MacOS/Console &' + +#--------------------------- +# System operations & info: +#--------------------------- +# repairpermissions +alias repairpermissions='sudo diskutil repairpermissions /' + +# install all software updates from the command line +alias software_update_cmd='COMMAND_LINE_INSTALL=1 export COMMAND_LINE_INSTALL; sudo softwareupdate -i -a' + +# third_party_kexts: to check for non-Apple kernel extensions +alias third_party_kexts='kextstat | grep -v com.apple' + +# show_optical_disk_info - e.g. what type of CD & DVD media is supported +alias show_optical_disk_info='drutil info' + +# remove_disk: spin down unneeded disk +# diskutil eject /dev/disk1s3 +alias nd0='diskutil eject /dev/disk0s3' +alias nd1='diskutil eject /dev/disk1s3' + +# mount_read_write: for use when booted into single-user +alias mount_read_write='/sbin/mount -uw /' + +# herr: shows the most recent lines from the HTTP error log +alias herr='tail /var/log/httpd/error_log' + +# use vsdbutil to show/change the permissions ignoring on external drives +# To ignore ownerships on a volume, do: sudo vsdbutil -d /VolumeName +# To restore ownerships on a volume, do: sudo vsdbutil -a /VolumeName +# To check the status of ownerships, do: sudo vsdbutil -c /VolumeName +alias ignore_permissions='sudo vsdbutil -d' + +# to change the password on anencrypted disk image: +# hdiutil chpass /path/to/the/diskimage + +# netparams: to show values of network parameters in the kernel +alias netparams='sysctl -a | grep net' + +# swapinfo: to display info on swap +alias swapinfo='sysctl vm.swapusage' + +# get info about system via AppleScript +# Note: this is rather slow - it is faster to run 'system_profiler' +# Note: to get computer name use: computer name of (system info) +applescript_info () +{ + info=$( /usr/bin/osascript <<" EOT" + system info + EOT + ) + echo $info +} + +# to mount a read-only disk image as read-write: +# hdiutil attach example.dmg -shadow /tmp/example.shadow -noverify + +# mounting a removable drive (of type msdos or hfs) +# mkdir /Volumes/Foo +# ls /dev/disk* to find out the device to use in the mount command) +# mount -t msdos /dev/disk1s1 /Volumes/Foo +# mount -t hfs /dev/disk1s1 /Volumes/Foo + +# to create a file of a given size: /usr/sbin/mkfile or /usr/bin/hdiutil +# e.g.: mkfile 10m 10MB.dat +# e.g.: hdiutil create -size 10m 10MB.dmg +# the above create files that are almost all zeros - if random bytes are desired +# then use: ~/Dev/Perl/randBytes 1048576 > 10MB.dat + +# making a hard-link backup of a directory +# rsync -a --delete --link-dest=$DIR $DIR /backup/path/for/dir + +# starting AFP file sharing +alias startFileSharing='sudo /usr/sbin/AppleFileServer' + +# hidden command line utilities: networksetup & systemsetup +alias networksetup='/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup' +alias systemsetup='/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup' +alias ardkickstart='/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart' + + +#-------- +# Finder: +#--------- +# show hidden files in Finder +alias finderShowHidden='defaults write com.apple.finder ShowAllFiles TRUE' +alias finderHideHidden='defaults write com.apple.finder ShowAllFiles FALSE' + +# finderTurnOffDesktop: turn off display of files on the Desktop +alias finderTurnOffDesktop='defaults write com.apple.finder CreateDesktop FALSE' + +# to stop Finder writing .DS_Store files on network volumes +# defaults write com.apple.desktopservices DSDontWriteNetworkStores true + +# lsregister: utility for looking at the Launch Services database +# e.g. 'lsregister -dump' to display database contents +# use 'lsregister -h' to get usage info +alias lsregister='/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister' + +# disable and re-enable Dashboard Widgets +alias disableDashboard='defaults write com.apple.dashboard mcx-disabled -bool YES; killall Dock' +alias enableDashboard='defaults delete com.apple.dashboard mcx-disabled; killAll Dock' + +# ql: show a "Quick Look" view of files +ql () { /usr/bin/qlmanage -p "$@" >& /dev/null & } + +# locateql: search using Spotlight and show a "Quick Look" of matching files +locateql () +{ + locatemd "$@" | enquote | xargs qlmanage -p >& /dev/null & +} + +#-------- +# Safari: +#-------- +# cleanup_favicons: clean up Safari favicons +alias cleanup_favicons='find $HOME/Library/Safari/Icons -type f -atime +30 -name "*.cache" -print -delete' + + +#----------------- +# Misc Reminders: +#----------------- + +# To find idle time: look for HIDIdleTime in output of 'ioreg -c IOHIDSystem' + +# to set the delay for drag & drop of text (integer number of milliseconds) +# defaults write -g NSDragAndDropTextDelay -int 100 + +# URL for a man page (example): x-man-page://3/malloc + +# to read a single key press: +alias keypress='read -s -n1 keypress; echo $keypress' + +# to compile an AppleScript file to a resource-fork in the source file: +osacompile_rsrc () { osacompile -x -r scpt:128 -o $1 $1; } + +# alternative to the use of 'basename' for usage statements: ${0##*/} + +# graphical operations, image manipulation: sips + +# numerical user id: 'id -u' +# e.g.: ls -l /private/var/tmp/mds/$(id -u) + diff --git a/plugins/dot-env/os/Darwin/path.sh b/plugins/dot-env/os/Darwin/path.sh new file mode 100644 index 000000000..3bf065fb1 --- /dev/null +++ b/plugins/dot-env/os/Darwin/path.sh @@ -0,0 +1 @@ +pathmunge "/Developer/usr/bin" diff --git a/plugins/dot-env/os/Linux/alias.sh b/plugins/dot-env/os/Linux/alias.sh new file mode 100644 index 000000000..dbcba66c2 --- /dev/null +++ b/plugins/dot-env/os/Linux/alias.sh @@ -0,0 +1,22 @@ +# Vi Editing and Sourcing aliases +alias ea='vi ~/.env/os/Linux/alias.sh' +alias eas='. ~/.env/os/Linux/alias.sh' +alias ees='. ~/.env/source.sh' +alias ef='vi ~/.env/os/Linux/functions.sh' +alias efs='. ~/.env/os/Linux/functions.sh' +alias ep='vi ~/.env/os/Linux/path.sh' +alias eps='. ~/.env/os/Linux/path.sh' +alias eh="vi ~/.env/host/$HOSTNAME/*.sh" +alias ehs=". ~/.env/host/$HOSTNAME/*.sh" + +# Directory Listing aliases +alias dir='ls -hFx' +alias l.='ls -d .* --color=auto' +alias l='ls -lathF --color=auto' +alias L='ls -latrhF' +alias ll='ls -lFh' +alias lo='ls -laSFh' +alias vdir='ls --color=auto --format=long' + +# Process Find Aliases +alias pfn='ps -e -o user,pid,args|grep' diff --git a/plugins/dot-env/os/Linux/env.sh b/plugins/dot-env/os/Linux/env.sh new file mode 100644 index 000000000..eb524363a --- /dev/null +++ b/plugins/dot-env/os/Linux/env.sh @@ -0,0 +1,5 @@ +# Misc +export EDITOR="vi" +export CVSEDITOR="$EDITOR" +export SVN_EDITOR="$EDITOR" +export VISUAL="$EDITOR" diff --git a/plugins/dot-env/os/Linux/functions.sh b/plugins/dot-env/os/Linux/functions.sh new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/dot-env/os/SunOS/alias.sh b/plugins/dot-env/os/SunOS/alias.sh new file mode 100644 index 000000000..7e52595ea --- /dev/null +++ b/plugins/dot-env/os/SunOS/alias.sh @@ -0,0 +1,4 @@ +# Solaris Environment Aliases + +# Editing and Sourcing aliases +alias ees='. ~/.env/source.sh' diff --git a/plugins/dot-env/os/SunOS/functions.sh b/plugins/dot-env/os/SunOS/functions.sh new file mode 100644 index 000000000..24a44fa3e --- /dev/null +++ b/plugins/dot-env/os/SunOS/functions.sh @@ -0,0 +1,13 @@ +function rgrep { + if [[ $# -lt 1 ]]; then + echo "Usage: rgrep PATTERN [PATH]" + return + fi + pattern="$1" + if [[ -z "$2" ]]; then + path=`pwd` + else + path="$2" + fi + find -L "$path"|xargs grep "$pattern" +} From 7f825441fcd510eb02257890ba31ca5d252deaf1 Mon Sep 17 00:00:00 2001 From: Chris Blackburn Date: Thu, 26 Jan 2012 14:03:29 -0600 Subject: [PATCH 2/4] minot tweaks --- plugins/dot-env/dot-env.plugin.zsh | 5 +++-- plugins/dot-env/os/Darwin/editor.sh | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/dot-env/dot-env.plugin.zsh b/plugins/dot-env/dot-env.plugin.zsh index cd887ef14..87d393e5d 100644 --- a/plugins/dot-env/dot-env.plugin.zsh +++ b/plugins/dot-env/dot-env.plugin.zsh @@ -37,10 +37,11 @@ for i in $OS_DIR/*.sh ; do done # Source Host specifics if there are any for the current host -if [[ ! -z "$HOST" ]]; then +HOSTNAME=`hostname` +if [[ ! -z "$HOSTNAME" ]]; then HOST_DIR=$DOT_ENV_PATH/host/`hostname` if [[ "$SHLVL" == "1" ]]; then - echo "Sourcing '$HOST' Environment" + echo "Sourcing '$HOSTNAME' Environment" fi for i in $HOST_DIR/*.sh ; do if [ -r "$i" ]; then diff --git a/plugins/dot-env/os/Darwin/editor.sh b/plugins/dot-env/os/Darwin/editor.sh index 0f6e99ea8..f6fff0560 100644 --- a/plugins/dot-env/os/Darwin/editor.sh +++ b/plugins/dot-env/os/Darwin/editor.sh @@ -5,14 +5,14 @@ # export EDITOR="$HOME/bin/mate2" # Sublime Text 2 Editor -export EDITOR="$HOME/bin/subl" +export EDITOR="$HOME/bin/subl -n" alias e="$EDITOR ." alias ea="$EDITOR $DOT_ENV_PATH/host/$HOSTNAME/alias.sh" alias eas=". $DOT_ENV_PATH/host/$HOSTNAME/alias.sh" alias eb="$EDITOR $HOME/bin" -alias ee="$EDITOR $DOT_ENV_PATH $HOME/.bashrc" -alias ees=". $DOT_ENV_PATH/source.sh" +alias ee="$EDITOR $DOT_ENV_PATH $HOME/.zshrc" +alias ees=". $DOT_ENV_PATH/dot-env.plugin.zsh" alias ef="$EDITOR $DOT_ENV_PATH/host/$HOSTNAME/functions.sh" alias efs=". $DOT_ENV_PATH/host/$HOSTNAME/functions.sh" alias eh="$EDITOR $HOME/.ssh" From 278616e95259f65ff9c4a738e76a23e9657b502a Mon Sep 17 00:00:00 2001 From: Chris Blackburn Date: Thu, 26 Jan 2012 17:19:11 -0600 Subject: [PATCH 3/4] Added readme, updated global functions and pathmunge to work properly --- plugins/dot-env/README.md | 80 +++++++++++++++ plugins/dot-env/global/global_functions.sh | 113 ++++++++++----------- plugins/dot-env/global/global_path.sh | 29 ++++-- 3 files changed, 154 insertions(+), 68 deletions(-) create mode 100644 plugins/dot-env/README.md diff --git a/plugins/dot-env/README.md b/plugins/dot-env/README.md new file mode 100644 index 000000000..ff858d471 --- /dev/null +++ b/plugins/dot-env/README.md @@ -0,0 +1,80 @@ +# dot-env for oh-my-zsh + +Adds 2 main features to oh-my-zsh: + +1. Ability to customize and maintain your oh-my-zsh environments based on global preferences, machine OS type (Darwin, Linux, Solaris), and hostname +1. Ability to cascade the customizations in hierarchical fashion from global, to os type, to specific hostname + +## Example + +Let's say you work on a Macbook Pro with a hostname "John-Smiths-Macbook-Pro", but you also frequently work on the following different remote machines over SSH: + +* rx23 - An Ubuntu 10.04 LTS box +* zebra - An Ubuntu 11.04 box +* sol-15 - A Solaris box +* technozero - A BSD box +* express - A CentOS box + +You already know, if you work on different remote machines, when you login the first time none of your aliases, shell functions or environment settings are there. What dot-env does is allow you to maintain a hierarchy of oh-my-zsh environment settings from global, down to specific host and to easily propagate those environments to each remote box from your local machine. + +So we can have a local hierarchy of settings like this: + + root + +- .oh-my-zsh + +- plugins + +- dot-env + +- global + +- global_aliases.sh + +- global_functions.sh + +- other_global_files.sh + +- os + +- Darwin + +- darwin_specific_aliases.sh + +- darwin_specific_functions.sh + +- etc.sh + +- Linux + +- SunOS + +- host + +- rx23 + +- rx23_specific_aliases.sh + +- rx23_specific_functions.sh + +- etc.sh + +- John-Smiths-Macbook-Pro.local + +- local_specific_aliases.sh + +- local_specific_functions.sh + +- local_etc.sh + +- etc... + +This hierarchy gets loaded in a cascading fashion as follows: + +- If you login to rx23: + 1. dot-env-plugin.zsh + 1. global/*.sh + 1. os/Linux/*.sh + 1. host/rx23/*.sh +- If you login to John-Smiths-Macbook-Pro + 1. dot-env-plugin.zsh + 1. global/*.sh + 1. os/Darwin/*.sh + 1. host/John-Smiths-Macbook-Pro.local/*.sh + +There are some helpful functions to maintain things: + + config_omzs_for_this_host # stubs out a hierarchy for the current host that you can edit to taste + + config_omzs_for_host # stubs out a hierarchy for a specified remote hostname + + propagate_omzs_to_host # copies your ~/.oh-my-zsh directory to a remote host + + load_omzs_on_alias # run this on a remote host to setup an alias 'omzs' to load oh-my-zsh + + load_omzs_on_login # run this on a remote host to have it automatically source oh-my-zsh on login + +* `config_omzs_for_this_host` - no arguments, just creates a directory structure for your local machine and stubs out a few .sh files + +* `config_omzs_for_host` - "Usage: config_omzs_for_host HOSTNAME" - creates a directory structure for your remote machine and stubs out a few .sh files + +* The `load_omzs_on_alias` function is nice if others also use that account and you don't want to force them to use your oh-my-zsh settings. + +* `propagate_omzs_to_host` - "Usage: propagate_omzs_to_host [user@]HOSTNAME" - compresses your `~/.oh-my-zsh` directory, uploads it to the specified host account, decompresses it and reminds you to run one of `load_omzs_on_alias` or `load_omzs_on_login` + diff --git a/plugins/dot-env/global/global_functions.sh b/plugins/dot-env/global/global_functions.sh index 5baae3549..f21867213 100644 --- a/plugins/dot-env/global/global_functions.sh +++ b/plugins/dot-env/global/global_functions.sh @@ -1,86 +1,85 @@ -# Add your public SSH key to a remote host -function add_ssh_key_to_host { - if [[ $# -lt 1 ]]; then - echo_warn "Usage: add_ssh_key_to_host [user@]HOSTNAME" - return - fi - if [[ -r ~/.ssh/id_dsa.pub ]]; then - cat ~/.ssh/id_dsa.pub | ssh $1 "cat >> .ssh/authorized_keys" - elif [[ -r ~/.ssh/id_rsa.pub ]]; then - cat ~/.ssh/id_rsa.pub | ssh $1 "cat >> .ssh/authorized_keys" +function load_omzs_on_login { + profile_file="$HOME/.zshrc" + if [[ -f "${profile_file}" ]] && + ! grep '$ZSH/oh-my-zsh.sh' "$profile_file" >/dev/null 2>&1 + then + echo '[[ -r $ZSH/oh-my-zsh.sh ]] && . $ZSH/oh-my-zsh.sh' >> "$profile_file" + echo "- oh-my-zsh will now load on login." + else + echo "- oh-my-zsh is already setup to load on login." fi + return 0 } -# Propagate your entire environment system to a remote host -function propagate_env_to_host { +function load_omzs_on_alias { + profile_file="$HOME/.zshrc" + if [[ -f "${profile_file}" ]] && + ! grep 'alias omzs=". $ZSH/oh-my-zsh.sh"' "$profile_file" >/dev/null 2>&1 + then + echo 'alias omzs=". $ZSH/oh-my-zsh.sh"' >> "$profile_file" + echo "- oh-my-zsh will now load when you execute 'omzs'." + else + echo "- oh-my-zsh is already setup to load using the 'omzs' alias." + fi + return 0 +} + + +# Propagate your environment system to a remote host +function propagate_omzs_to_host { if [[ $# -lt 1 ]]; then - echo_warn "Usage: propagate_env_to_host [user@]HOSTNAME" + echo "Usage: propagate_omzs_to_host [user@]HOSTNAME" return fi host=$1 - shift 1 - ENVFILE=$HOME/env.tar.gz + OH_MY_ZSH=$HOME/env.tar.gz PWD=`pwd` cd $HOME - echo_info "Compressing local environment..." - tar cfvz $ENVFILE .env/ &> /dev/null - echo_info "Copying environment to $host..." - scp $ENVFILE $host: - if [[ $? != 0 ]]; then echo "Copy failed!"; return; fi - echo_info "Installing environment on $host..." - ssh $host "rm -rf ~/.env/ && gunzip < env.tar.gz |tar xfv -" &> /dev/null - echo_warn "Don't forget to add this your .bashrc file:" - echo_warn 'if [[ -n "$PS1" ]]; then' - echo_warn ' [[ -r $HOME/.env/source.sh ]] && . $HOME/.env/source.sh' - echo_warn 'fi' + echo "- compressing local environment..." + tar cfvz $OH_MY_ZSH .oh-my-zsh/ &> /dev/null + echo "- copying environment to $host..." + scp $OH_MY_ZSH $host: + if [[ $? != 0 ]]; then echo "> remote copy failed [scp $OH_MY_ZSH $host]!"; return; fi + echo "- installing environment on $host..." + ssh $host "rm -rf ~/.oh-my-zsh/ && gunzip < env.tar.gz |tar xfv -" &> /dev/null + echo "- done. don't forget to run 'load_omzs_on_login' or 'load_omzs_on_alias'" cd $PWD } +function _stub_new_host_environment { + mkdir -p $1 + touch "$1/env.sh" + touch "$1/functions.sh" + if [[ ! -f "$1/alias.sh" ]]; then + echo "# Add your host specific aliases here:\n# Example: alias home='cd \$HOME' " >> "$1/alias.sh" + fi + if [[ ! -f "$1/path.sh" ]]; then + echo "# Add paths like this:\n# pathmunge \"/Developer/usr/bin\"" >> "$1/path.sh" + fi +} + # Configure environment settings for your local machine. -function configthis.env { +function config_omzs_for_this_host { DIR="$DOT_ENV_PATH/host/$HOSTNAME" - mkdir -p "$DIR" - touch "$DIR/env.sh" - touch "$DIR/functions.sh" - if [[ ! -f "$DIR/alias.sh" ]]; then - echo "# Add your specific aliases here:\n# Example: alias home='cd \$HOME' " >> "$DIR/alias.sh" - fi - if [[ ! -f "$DIR/prompt.sh" ]]; then - echo "# Define your prompt here:\n# Example: PS1=\$BLUE\u@\H\$NO_COLOR " >> "$DIR/prompt.sh" - fi - if [[ ! -f "$DIR/path.sh" ]]; then - echo "# Add paths like this:\n# pathmunge \"/Developer/usr/bin\"" >> "$DIR/path.sh" - fi + _stub_new_host_environment $DIR cd "$DIR" - echo_info "Edit these files to customize your local environment." + echo "- edit these files to customize your local environment." ls -1AtF } # Configure environment settings for a specified HOSTNAME -function confighost.env { +function config_omzs_for_host { if [[ $# -lt 1 ]]; then - echo_warn "Usage: confighost.env HOSTNAME" + echo_warn "Usage: config_omzs_for_host HOSTNAME" return fi host=$1 - shift 1 DIR="$DOT_ENV_PATH/host/$host" - mkdir -p "$DIR" - touch "$DIR/env.sh" - touch "$DIR/functions.sh" - if [[ ! -f "$DIR/alias.sh" ]]; then - echo "# Add your host specific aliases here:\n# Example: alias home='cd \$HOME' " >> "$DIR/alias.sh" - fi - if [[ ! -f "$DIR/prompt.sh" ]]; then - echo "# Define your prompt here:\n# Example: PS1=\$BLUE\u@\H\$NO_COLOR " >> "$DIR/prompt.sh" - fi - if [[ ! -f "$DIR/path.sh" ]]; then - echo "# Add paths like this:\n# pathmunge \"/Developer/usr/bin\"" >> "$DIR/path.sh" - fi + _stub_new_host_environment $DIR cd "$DIR" - echo_info "Edit these files to customize your [$host] environment." - echo_info "When you are finished run 'propagate_env_to_host $host'." + echo "- edit these files to customize your [$host] environment." + echo "- when you are finished run 'propagate_omzs_to_host $host'." ls -1AtF } diff --git a/plugins/dot-env/global/global_path.sh b/plugins/dot-env/global/global_path.sh index 1b49b79ec..b78e96dc7 100644 --- a/plugins/dot-env/global/global_path.sh +++ b/plugins/dot-env/global/global_path.sh @@ -1,20 +1,26 @@ -paths="${DOT_ENV_PATH}/bin -/sbin +paths=( /bin -/usr/X11/bin +/sbin /usr/local/bin +/usr/local/sbin +/usr/bin /usr/sbin -/usr/bin" +/usr/X11/bin +) EGREP=`which egrep` function pathmunge () { - if ! echo $PATH | $EGREP "(^|:)$1($|:)" > /dev/null ; then - if [ -d "$1" ]; then - if [ "$2" = "before" ] ; then - PATH="$1:$PATH" - else - PATH="$PATH:$1" - fi + # If it exists then remove it so we can shuffle it to the end or beginning of the PATH + if echo $PATH | $EGREP "(^|:)$1($|:)" > /dev/null ; then + safe_param=$(printf "%s\n" "$1" | sed 's/[][\.*^$(){}?+|/]/\\&/g') + PATH=`echo $PATH | sed -Ee "s/(^|:)$safe_param($|:)/:/"` + fi + # add the path in the apropriate location + if [ -d "$1" ]; then + if [ "$2" = "before" ] ; then + PATH="$1:$PATH" + else + PATH="$PATH:$1" fi fi } @@ -26,6 +32,7 @@ done # Prepend path with $HOME/bin pathmunge "$HOME/bin" before +# Remove : at the beginning and duplicate :: PATH=`echo $PATH | sed -e 's/^\://' -e 's/\:\:/:/g'` unset paths export PATH From 85962059dee9b5aa9b9c32b5c0251884fd0eedde Mon Sep 17 00:00:00 2001 From: Chris Blackburn Date: Thu, 26 Jan 2012 17:23:52 -0600 Subject: [PATCH 4/4] Updated README.md and added the add_ssh_key_to_host shell function --- plugins/dot-env/README.md | 4 +++ plugins/dot-env/global/global_functions.sh | 30 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/plugins/dot-env/README.md b/plugins/dot-env/README.md index ff858d471..4d761aec5 100644 --- a/plugins/dot-env/README.md +++ b/plugins/dot-env/README.md @@ -64,6 +64,8 @@ There are some helpful functions to maintain things: config_omzs_for_host # stubs out a hierarchy for a specified remote hostname + add_ssh_key_to_host # copy your .ssh/id_rsa.pub or id_dsa.pub key to a remote host + propagate_omzs_to_host # copies your ~/.oh-my-zsh directory to a remote host load_omzs_on_alias # run this on a remote host to setup an alias 'omzs' to load oh-my-zsh @@ -74,6 +76,8 @@ There are some helpful functions to maintain things: * `config_omzs_for_host` - "Usage: config_omzs_for_host HOSTNAME" - creates a directory structure for your remote machine and stubs out a few .sh files +* `add_ssh_key_to_host` - "Usage: add_ssh_key_to_host [user@]HOSTNAME" - Add your public SSH key to a remote host. You may have to enter your password up to 3 times. After that it will be passwordless if the remote sshd server is setup to allow it + * The `load_omzs_on_alias` function is nice if others also use that account and you don't want to force them to use your oh-my-zsh settings. * `propagate_omzs_to_host` - "Usage: propagate_omzs_to_host [user@]HOSTNAME" - compresses your `~/.oh-my-zsh` directory, uploads it to the specified host account, decompresses it and reminds you to run one of `load_omzs_on_alias` or `load_omzs_on_login` diff --git a/plugins/dot-env/global/global_functions.sh b/plugins/dot-env/global/global_functions.sh index f21867213..5338366fd 100644 --- a/plugins/dot-env/global/global_functions.sh +++ b/plugins/dot-env/global/global_functions.sh @@ -24,6 +24,36 @@ function load_omzs_on_alias { return 0 } +# Add your public SSH key to a remote host +# You may have to enter your password up to 3 times. +# After that it will be passwordless if the remote sshd server is setup to allow it +function add_ssh_key_to_host { + if [[ $# -lt 1 ]]; then + echo "Usage: add_ssh_key_to_host [user@]HOSTNAME" + return + fi + + # First check that the account has an authorized_keys file + ssh_dir='~/.ssh' + authorized_keys_file='authorized_keys' + output=`ssh $1 "ls -1 $ssh_dir" stderr 2> /dev/null` + if [[ "$output" =~ "authorized_keys" ]]; then + echo "- appending [$1]: $ssh_dir/$authorized_keys_file" + else + echo "- creating [$1]: $ssh_dir/$authorized_keys_file" + output=`ssh $1 "mkdir -p $ssh_dir && touch $ssh_dir/$authorized_keys_file && chmod 700 $ssh_dir && chmod 600 $ssh_dir/$authorized_keys_file"` + fi + + # Use DSA key by default, fallback to RSA key + if [[ -r ~/.ssh/id_dsa.pub ]]; then + echo "- using your DSA key" + cat ~/.ssh/id_dsa.pub | ssh $1 "cat >> $ssh_dir/$authorized_keys_file" + elif [[ -r ~/.ssh/id_rsa.pub ]]; then + echo "- using your RSA key" + cat ~/.ssh/id_rsa.pub | ssh $1 "cat >> $ssh_dir/$authorized_keys_file" + fi + echo "- ssh logins should now be passwordless on [$1]" +} # Propagate your environment system to a remote host function propagate_omzs_to_host {