diff --git a/dotfiles/lib/shellrc.sh b/dotfiles/lib/shellrc.sh index f2b2bbfd..d60bc57c 100644 --- a/dotfiles/lib/shellrc.sh +++ b/dotfiles/lib/shellrc.sh @@ -1,33 +1,3 @@ -function add_to_front_of_path { - export PATH=$@:$(echo $PATH | sed "s|:*$@||g" | sed "s|^:||") -} - -function add_to_back_of_path { - export PATH=$(echo $PATH | sed "s|:*$@||g" | sed "s|^:||"):$@ -} - -add_to_back_of_path "$HOME/.local/lib/python2.6/site-packages" -hash brew 2>/dev/null && add_to_front_of_path "$(brew --prefix coreutils)/libexec/gnubin" -add_to_front_of_path "/usr/local/bin" -hash brew 2>/dev/null && add_to_front_of_path "$(brew --prefix emacs)/libexec/gnubin" - for filename in ~/.lib/shellrc/*; do source $filename done - -if is_osx; then - export CFLAGS=-Qunused-arguments - export CPPFLAGS=-Qunused-arguments - add_to_back_of_path "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/" - export JAVA_HOME="$(find /Library/Java/JavaVirtualMachines -depth 1 | head -n 1)/Contents/Home" - # Access gnu man pages. - hash brew 2> /dev/null && export MANPATH="$(brew --prefix)/opt/coreutils/libexec/gnuman:$MANPATH" -else - export JAVA_HOME="$(update-alternatives --config java | get_cols ' -1' | head -n 1)" - is_osx && export VISUAL="which emacsclient -c -n" -fi - -add_to_front_of_path "$JAVA_HOME/bin" - -add_to_back_of_path "$(dotfiles_directory)/resources/python" -add_to_back_of_path "/usr/local/sbin" diff --git a/dotfiles/lib/shellrc/colors.sh b/dotfiles/lib/shellrc/colors.sh deleted file mode 100644 index 2ad5537f..00000000 --- a/dotfiles/lib/shellrc/colors.sh +++ /dev/null @@ -1,3 +0,0 @@ -dircolors_file="$HOME/.dircolors" - -[ ! -z "$SHELL" ] && test -r $dircolors_files && eval "$(dircolors $dircolors_file)" diff --git a/dotfiles/lib/shellrc/emacs.sh b/dotfiles/lib/shellrc/emacs.sh index fd49c618..fdfa3a3d 100644 --- a/dotfiles/lib/shellrc/emacs.sh +++ b/dotfiles/lib/shellrc/emacs.sh @@ -1,13 +1,17 @@ -alias emacs='cemacs' -alias cemacs='_emacs -c -n' -alias temacs='_emacs -t' +alias emacs='temacs' +is_osx && alias emacs='cocoa_emacs' +alias terminal_emacs='_emacs -t' alias ec='_emacs -n ' +function cocoa_emacs { + reattach-to-user-namespace zsh -c "source ~/.zshrc && _emacs -c -n" +} + function _emacs { local server_name="$(_current_dot_directory)" if ! _emacs_daemon_exists "$server_name"; then echo "Starting emacs with server name '$server_name'" - \emacs --daemon="$server_name" + command emacs --daemon="$server_name" fi emacsclient $* --server-file=$server_name } diff --git a/dotfiles/lib/shellrc/osx.sh b/dotfiles/lib/shellrc/osx.sh index 17b5f7e0..555cc61b 100644 --- a/dotfiles/lib/shellrc/osx.sh +++ b/dotfiles/lib/shellrc/osx.sh @@ -75,3 +75,11 @@ function set_modifier_keys_on_all_keyboards() { function get_keyboard_vendor_id_product_id_pairs() { ioreg -n IOHIDKeyboard -r | grep -e 'class IOHIDKeyboard' -e VendorID\" -e Product | gawk 'BEGIN { RS = "class IOHIDKeyboard" } match($0, /VendorID. = ([0-9]*)/, arr) { printf arr[1]} match($0, /ProductID. = ([0-9]*)/, arr) { printf " %s\n", arr[1]} ' } + +function set_osx_hostname() { + local new_hostname="${1-imalison}" + 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/dotfiles/lib/shellrc/vim.sh b/dotfiles/lib/shellrc/vim.sh deleted file mode 100644 index ea183fec..00000000 --- a/dotfiles/lib/shellrc/vim.sh +++ /dev/null @@ -1,3 +0,0 @@ -function vimstall() { - vim +BundleInstall! +q +q -} diff --git a/dotfiles/lib/zsh/completion.sh b/dotfiles/lib/zsh/completion.sh index b649fd33..11f33b1e 100644 --- a/dotfiles/lib/zsh/completion.sh +++ b/dotfiles/lib/zsh/completion.sh @@ -94,3 +94,10 @@ zstyle ':completion:*:(ssh|scp):*:hosts-ipaddr' ignored-patterns \ '^<->.<->.<->.<->' '127.0.0.<->' zstyle ':completion:*:(ssh|scp):*:users' ignored-patterns \ adm bin daemon halt lp named shutdown sync + +zstyle -e ':completion:*:(ssh|scp):*' hosts 'reply=( + ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) \ + /dev/null)"}%%[# ]*}//,/ } + ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*} + ${=${${${${(@M)${(f)"$(<~/.ssh/config)"}:#Host *}#Host }:#*\**}:#*\?*}} + )' diff --git a/dotfiles/tmux.conf b/dotfiles/tmux.conf index bb1f28cf..6e592574 100644 --- a/dotfiles/tmux.conf +++ b/dotfiles/tmux.conf @@ -1,3 +1,5 @@ +set-option -g default-command "reattach-to-user-namespace -l zsh" + unbind C-g set -g prefix C-o bind-key C-o send-prefix diff --git a/dotfiles/zshenv b/dotfiles/zshenv index 2aef46f0..4a7b1cad 100644 --- a/dotfiles/zshenv +++ b/dotfiles/zshenv @@ -1,25 +1,30 @@ -# ssh, scp, ping, host -zstyle ':completion:*:scp:*' tag-order \ - 'hosts:-host hosts:-domain:domain hosts:-ipaddr:IP\ address *' -zstyle ':completion:*:scp:*' group-order \ - users files all-files hosts-domain hosts-host hosts-ipaddr -zstyle ':completion:*:ssh:*' tag-order \ - users 'hosts:-host hosts:-domain:domain hosts:-ipaddr:IP\ address *' -zstyle ':completion:*:ssh:*' group-order \ - hosts-domain hosts-host users hosts-ipaddr +source ~/.lib/shellrc/functions.sh +function add_to_front_of_path { + export PATH=$@:$(echo $PATH | sed "s|:*$@||g" | sed "s|^:||") +} -zstyle ':completion:*:(ssh|scp):*:hosts-host' ignored-patterns \ - '*.*' loopback localhost -zstyle ':completion:*:(ssh|scp):*:hosts-domain' ignored-patterns \ - '<->.<->.<->.<->' '^*.*' '*@*' -zstyle ':completion:*:(ssh|scp):*:hosts-ipaddr' ignored-patterns \ - '^<->.<->.<->.<->' '127.0.0.<->' -zstyle ':completion:*:(ssh|scp):*:users' ignored-patterns \ - adm bin daemon halt lp named shutdown sync +function add_to_back_of_path { + export PATH=$(echo $PATH | sed "s|:*$@||g" | sed "s|^:||"):$@ +} -zstyle -e ':completion:*:(ssh|scp):*' hosts 'reply=( - ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) \ - /dev/null)"}%%[# ]*}//,/ } - ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*} - ${=${${${${(@M)${(f)"$(<~/.ssh/config)"}:#Host *}#Host }:#*\**}:#*\?*}} - )' \ No newline at end of file +add_to_back_of_path "$HOME/.local/lib/python2.6/site-packages" +hash brew 2>/dev/null && add_to_front_of_path "$(brew --prefix coreutils)/libexec/gnubin" +add_to_front_of_path "/usr/local/bin" +hash brew 2>/dev/null && add_to_front_of_path "$(brew --prefix emacs)/libexec/gnubin" + +if is_osx; then + export CFLAGS=-Qunused-arguments + export CPPFLAGS=-Qunused-arguments + add_to_back_of_path "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/" + export JAVA_HOME="$(find /Library/Java/JavaVirtualMachines -depth 1 | head -n 1)/Contents/Home" + # Access gnu man pages. + hash brew 2> /dev/null && export MANPATH="$(brew --prefix)/opt/coreutils/libexec/gnuman:$MANPATH" +else + export JAVA_HOME="$(update-alternatives --config java | get_cols ' -1' | head -n 1)" + is_osx && export VISUAL="which emacsclient -c -n" +fi + +add_to_front_of_path "$JAVA_HOME/bin" + +add_to_back_of_path "$(dotfiles_directory)/resources/python" +add_to_back_of_path "/usr/local/sbin"