Major revamp of shell init - drop bash support, focus on zsh

This commit is contained in:
2018-07-20 00:46:33 +01:00
parent 582a97c7af
commit a53788f5c4
39 changed files with 210 additions and 649 deletions

6
.gitignore vendored
View File

@@ -1,10 +1,12 @@
.AppleDouble
Icon*
.SyncArchive/*
.SyncID
.SyncIgnore
.SyncArchive/*
.dropbox
Icon*
bin/boot2docker.iso
bundle/cache/*
private/*
tmux/plugins/*
zsh/zplug/cache/*
zsh/zplug/repos/*

11
.gitmodules vendored
View File

@@ -4,15 +4,12 @@
[submodule "private"]
path = private
url = git@bitbucket.org:jimeh/dotfiles-private.git
[submodule "shell/tmux/tmuxifier"]
path = shell/tmux/tmuxifier
[submodule "tmux/tmuxifier"]
path = tmux/tmuxifier
url = git@github.com:jimeh/tmuxifier.git
[submodule "shell/bash/git-aware-prompt"]
path = shell/bash/git-aware-prompt
url = git@github.com:jimeh/git-aware-prompt.git
[submodule "tmux/plugins/tpm"]
path = tmux/plugins/tpm
url = https://github.com/tmux-plugins/tpm
[submodule "shell/zsh/zplug"]
path = shell/zsh/zplug
[submodule "zsh/zplug/zplug"]
path = zsh/zplug/zplug
url = https://github.com/zplug/zplug

View File

@@ -1,8 +1,13 @@
.PHONY: backup-zplug-cache
backup-zplug-cache:
cd shell/zsh \
&& tar -cjf zplug-cache-$(shell date "+%Y-%m-%d").tar.bz2 zplug-cache
.PHONY: backup-zplug
backup-zplug: \
zsh/zplug-$(shell date "+%Y-%m-%d").tar.bz2
.PHONY: backup-tmux-plugins
backup-tmux-plugins:
cd tmux && tar -cjf tmux-plugins-$(shell date "+%Y-%m-%d").tar.bz2 plugins
backup-tmux-plugins: \
tmux/tmux-plugins-$(shell date "+%Y-%m-%d").tar.bz2
zsh/zplug-%.tar.bz2: zsh/zplug
cd zsh && tar -cjf "$(shell basename "$@")" zplug
tmux/tmux-plugins-%.tar.bz2: tmux/plugins
cd tmux && tar -cjf "$(shell basename "$@")" plugins

View File

@@ -32,7 +32,7 @@ SYMLINKS=(
tmux
tmux.conf
)
LOAD_FILES=(profile zshrc)
LOAD_FILES=(zshrc)
#

View File

@@ -1 +1 @@
source "$HOME/.dotfiles/shellrc.sh"
source "$HOME/.dotfiles/zshrc.zsh"

View File

@@ -1,51 +0,0 @@
#
# Main Shell Setup
#
# Ensure 256 color support in Linux
if [[ "$(uname)" == "Linux" ]]; then
export TERM="xterm-256color"
fi
# Set required path variables
DOTBIN="$DOTFILES/bin"
# Helper Functions
source "$DOTSHELL/helpers.sh"
# Ensure /usr/local/bin is before various system-paths
path_prepend "/usr/local/bin"
# Load bash or zsh specific init files
if [ -n "$BASH_VERSION" ]; then
source "$DOTSHELL/bashrc.sh"
elif [ -n "$ZSH_VERSION" ]; then
source "$DOTSHELL/zshrc.zsh"
fi
# 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"
source "$DOTSHELL/tmux.sh"
source "$DOTSHELL/less.sh"
# Development
source "$DOTSHELL/nodejs.sh"
source "$DOTSHELL/ruby.sh"
source "$DOTSHELL/rust.sh"
source "$DOTSHELL/golang.sh"
source "$DOTSHELL/docker.sh"
source "$DOTSHELL/google-cloud.sh"
source "$DOTSHELL/kubernetes.sh"
# Environment Setup
source "$DOTSHELL/env.sh"
source "$DOTSHELL/tmpdir.sh"

View File

@@ -1,374 +0,0 @@
## bash-ido - attempt to simulate a interactive menu similar to
# ido-mode in emacs
#
# URL: http://pgas.freeshell.org/shell/bash-ido
# Author: <pierre.gaston@gmail.com>
# Version: 1.0beta2
# CVS: $Id: bash-ido,v 1.18 2010/02/13 14:50:32 pgas Exp $
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with BASH-IDO; see the file COPYING. If not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# Documentation:
# --------------
# This is a fairly complex completion script for cd. (For now, i tried
# to make the functions a bit generic so that the menu can be used for
# other completions. Let me know if you need some help or something)
# It mimics what ido-mode does in emacs.This script also masks the
# normal cd with a function to track the list of the directory
# used. It's easier to try than to describe, here is a little getting
# started:
#
# 0) Source this script in your .bashrc (. /path/to/bash-ido)
# 1) Start your cd command, press TAB, type some letters the list of dirs is
# filtered according to these letters.
# 2) Press RET to select the first dir in the list.
# 3) DEL ie the erase key (usually backspace or ^H), to delete a search letter.
# When there are no more letters, pressing DEL let you go up one dir.
# 4) C-s or <right> cycles the list to the right, C-r or <left> to the left
# 5) C-g or C-c cancels the completion.
# 6) Typing 2 / will put you in /, typing /~/ will put you in $HOME
# 7) up/M-s and down/M-r allows to navigate in the history
# Limitations
# -----------
# * You cannot start completion after a dirname in " " or ' '
# (actually it's probably possible if you modify COMP_WORDBREAKS)
# * It doesn't expand the ~user/ dirs, if you need this please tell me
# * The completion disables and re-enables C-c using stty,
# if you use another char for intr you need to modify
# the hard coded value (search for $'\003') this could be found via stty
# or a parameter could be defined but how well....tell me if you feel this
# is needed.
# * It probably doesn't work too well with huge dirs (a security check could
# perhaps be implemented).
# Implementation Notes:
# ---------------------
# * Not sure what bash version is required.
# * It Probably doesn't work too well with some strange filenames.
# * All the functions and variables in this file should be prefixed by _ido_
# to avoid namespace polution
# * Use stty rather than a trap to disable sigint....I couldn't do what
# I wanted with trap.
# * I choose to use the hardcoded ansi codes rather than tput, it should be
# a tad faster and reduce the dependencies, if you it doesn't work in your
# terminal please tell me.
# TODO:
# -----
# * add an example for other completions
# * support for CDPATH in dir completion?
# * implement persitent history?
# * complete on ~ first and handle ~user?
# Global vars
# -----------
# _ido_menu -- the list of choices
# _ido_f_menu -- the filtered menu
# _ido_search_string -- the characters typed so far
# _ido_result -- the dirname part of the search
_ido_history_size=100 # -- maximum dir entries in the history
# _ido_history -- list of the directories in the history
# _ido_history_point -- pointer to the current history entry
# Functions
# ---------
# _ido_print_menu -- print the filtered menu
# _ido_loop -- the main keyboard event loop
# _ido_filter -- filters the menu
# _ido_gen_dir -- generate the original menu (list of dirs)
# _ido_dir -- entry point
# Changes
# -------
# 1.0b2
# * fix ../ behaviour
# * fix TAB behaviour
shopt -s checkwinsize #so that COLUMNS stays up to date
_ido_print_f_menu () {
# Prints the directories limited on one line...
# We would need some terminal commands to clear more than one line
local prompt menu i cur
prompt=${_ido_result}${_ido_search_string}
if (( ${#_ido_f_menu[@]} ));then
menu="{ ${_ido_f_menu[0]#* }"
i=1
while cur=${_ido_f_menu[i]#* };
(( i < (${#_ido_f_menu[@]} -1)
&& (${#menu}+${#prompt} +${#cur}+11) < COLUMNS )) \
|| (( i == (${#_ido_f_menu[@]} -1)
&& (${#menu}+${#prompt}+${#cur}+4) < COLUMNS)); do
menu+=" | ${cur}"
i=$((i+1))
done
if ((i < (${#_ido_f_menu[@]} -1) )) ; then
menu+=" | ... }"
else
menu+=" }"
fi
#yet another hack to put the cursor after the search string.
printf "\r%*s\r%*s%s\r%s" $COLUMNS " " ${#prompt} " " "$menu" "$prompt"
else
printf "\r%*s\r%*s%s\r%s" $COLUMNS " " ${#prompt} " " "[ No Match]" "$prompt"
fi
}
_ido_filter () {
local i start trans_i cas quoted
if shopt -q nocasematch;then
cas=set
else
shopt -s nocasematch
fi
start=${_ido_f_menu[i]%% *}
unset _ido_f_menu
if [[ "$_ido_search_string" ]];then
printf -v quoted "%q" "$_ido_search_string"
else
quoted=""
fi
for i in "${!_ido_menu[@]}";do
trans_i=$(((i+start)%${#_ido_menu[@]}))
if [[ "${_ido_menu[trans_i]}" = *"$quoted"* ]];then
_ido_f_menu+=( "$trans_i ${_ido_menu[trans_i]}" )
fi
done
if [[ -z $cas ]];then
shopt -u nocasematch
fi
}
_ido_loop () {
local REPLY c
while :;do
_ido_print_f_menu >&2
unset c
while :;do
#loop to read the escape sequences
IFS= read -d '' -r -s -n 1
case $REPLY in
$'\E')
c+=$REPLY
;;
\[|O)
c+=$REPLY
if ((${#c} ==1));then
break
fi
;;
*)
c+=$REPLY
break
;;
esac
done
case $c in
$'\n'|$'\t') # RET
_ido_result="${_ido_result}${_ido_f_menu[0]#* }"
return 0
;;
/ ) # /
case $_ido_search_string in
..)
_ido_result+="../"
;;
\~)
_ido_result="$HOME/"
;;
?*)
_ido_result="${_ido_result}${_ido_f_menu[0]#* }"
;;
*)
_ido_result=/
;;
esac
return 0
;;
'$\b'|$'\177') #DEL aka ^? or ^h
if [[ $_ido_search_string ]]; then
_ido_search_string=${_ido_search_string%?}
_ido_filter
else
_ido_result+="../"
return 0
fi
;;
$'\a' | $'\003') # C-g | C-c
return 2
;;
$'\E[C'|$'\EOC'|$'\023') #<right> | C-s
if ((${#_ido_f_menu[@]}>1));then
_ido_f_menu=("${_ido_f_menu[@]:1}" "${_ido_f_menu[0]}")
fi
;;
$'\E[D'|$'\EOD'|$'\022') #<left> | C-r
if ((${#_ido_f_menu[@]}>1));then
_ido_f_menu=("${_ido_f_menu[${#_ido_f_menu[@]}-1]}"
"${_ido_f_menu[@]:0:${#_ido_f_menu[@]}-1}")
fi
;;
$'\E[B'|$'\EOB'|$'\367'|$'\Er') # <down> | M-r
if ((_ido_history_point>1));then
_ido_history_point=$((_ido_history_point-1))
_ido_result=${_ido_history[_ido_history_point]%/}/
_ido_search_string=""
return 0
else
printf "\a" >&2
fi
;;
$'\E[A'|$'\EOA'|$'\362'|$'\Es') # <up> | M-s
if (((_ido_history_point+1)< ${#_ido_history[@]}));then
_ido_history_point=$((_ido_history_point+1))
_ido_result=${_ido_history[_ido_history_point]%/}/
_ido_search_string=""
return 0
else
printf "\a" >&2
fi
;;
[[:print:]])
_ido_search_string+=$REPLY
_ido_filter
;;
*)
printf "\a" >&2
# printf "%q\n" "$c"
;;
esac
done
}
_ido_gen_dir () {
# return a list of subdir in _ido_result,
local pattern
case $_ido_search_string in
..)
pattern=../
;;
.)
pattern="./ ..?*/ .[!.]*/ */"
;;
.?*)
pattern="..?*/ .[!.]*/ */"
;;
*)
pattern="./ */ ..?*/ .[!.]*/"
;;
esac
_ido_result=${_ido_result/#~\//$HOME/}
unset _ido_menu
IFS=$'\n' read -r -d '' -a _ido_menu \
< <(IFS=" ";shopt -s nullglob;\
eval command cd "$_ido_result" 2>/dev/null \
&& printf -- "%q\n" $pattern)
if [[ $_ido_search_string ]];then
_ido_filter
else
local i e
unset _ido_f_menu
for e in "${_ido_menu[@]}";do
_ido_f_menu[i]="$i $e"
i=$((i+1))
done
fi
_ido_result="${_ido_result/#$HOME\//~/}"
}
_ido_dir () {
_ido_result=${COMP_WORDS[COMP_CWORD]}
if [[ "$_ido_result" == \$* ]]; then
if [[ "$_ido_result" == */* ]];then
local temp
temp=${_ido_result%%/*}
temp=${temp#?}
_ido_result=${!temp}/${_ido_result#*/}
else
COMPREPLY=( $( compgen -v -P '$' -- "${_ido_result#$}" ) )
return 0
fi
fi
stty intr undef
local status
unset _ido_f_menu _ido_search_string _ido_history_point
printf '\E7' #tput sc = save cursor
status=0
case $_ido_result in
''|.|./ )
_ido_result=$PWD/
;;
*/*)
_ido_search_string=${_ido_result##*/}
_ido_result=${_ido_result%/*}/
_ido_result=${_ido_result/#~\//$HOME/}
if [[ ! -d ${_ido_result} ]]; then
printf "\a\nNo Such Directory: %s\n" "${_ido_result}" >&2
status=1
fi
;;
*)
_ido_search_string=$_ido_result
_ido_result=$PWD/
;;
esac
# normalize ie remove the // and other foo/../bar
_ido_result=$(command cd "$_ido_result" && printf "%q" "${PWD%/}/")
while [[ $status = 0 && $_ido_result != */./ ]]; do
# hmm this part is dir specific...TB generalized..
case $_ido_result in
# order is important, the last case covers the first ones
/../)
_ido_result=/
;;
\~/../)
_ido_result=${HOME%/*}/
;;
*/../)
_ido_result=${_ido_result%/*/../}/
;;
esac
_ido_gen_dir
_ido_loop; status=$?
_ido_search_string=""
done
printf "\r%*s\E8" $COLUMNS # clear the line, tput rc restore the cursor
kill -WINCH $$ # force bash to redraw
stty intr $'\003'
if [[ $status = 0 ]]; then
# gives the _ido_result to bash
COMPREPLY[0]=${_ido_result%./}
fi
return $status
}
complete -F _ido_dir -o nospace cd
cd () {
if command cd "$@";then
_ido_history=($(printf "%s\n" "$PWD" "${_ido_history[@]}" |\
awk -v s="$_ido_history_size" '!a[$0]++;(i++==s-1){exit}'))
fi
}
### Local Variables:
### mode: shell-script
### End:

View File

@@ -1,14 +0,0 @@
#
# Bash Prompt
#
# Setup and use git-aware-prompt
if [ -f "$DOTBASH/git-aware-prompt/main.sh" ]; then
GITAWAREPROMPT="$DOTBASH/git-aware-prompt"
source "$GITAWAREPROMPT/main.sh"
export PS1="\u@\h \w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
export SUDO_PS1="\[$bakred\]\u@\h\[$txtrst\] \w\$ "
else
# Customize prompt to act like pre-leopard
PS1='\h:\w \u$ '
fi

View File

@@ -1,14 +0,0 @@
#
# Bash Init
#
# Deterimine current directory
DOTBASH="$DOTSHELL/bash"
# bash-completion
if [ -f /usr/local/etc/bash_completion ]; then
source /usr/local/etc/bash_completion
fi
source "$DOTBASH/prompt.sh"
# source "$DOTBASH/bash-ido.sh" # Disabled for making life complicated

View File

@@ -1,23 +0,0 @@
#
# Environment Setup
#
# Editors
export EDITOR="emacsclient-wrapper"
export GEM_EDITOR="mate"
# Locale Setup
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
# ensure bin and sbin paths from /usr/local are in PATH
path_add_after "/usr/local/sbin" "/usr/local/bin"
# ensure bin and sbin paths from /usr are in PATH
path_add_after "/usr/sbin" "/usr/bin"
# Add user's bin directory to PATH
path_prepend "$HOME/bin"
# Add dotfiles' bin directory to PATH
path_prepend "$DOTBIN"

View File

@@ -1,8 +0,0 @@
#
# Helper Functions
#
DOTHELPERS="$DOTSHELL/helpers"
# Load helpers
source "$DOTHELPERS/path_helpers.sh"

View File

@@ -1,39 +0,0 @@
#
# 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 \
'<dict><key>enabled</key><false/></dict>'
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
}

View File

@@ -1,3 +0,0 @@
# Aliases
alias svnadderall="svn status | grep '^?' | cut -b 8- | xargs svn add"
alias svnridallin="svn status | grep '^!' | cut -b 8- | xargs svn remove --keep-local"

View File

@@ -1,9 +0,0 @@
#
# TMPDIR setup
#
# Ensure TMPDIR is the same for local and remote ssh logins
if [[ $TMPDIR == "/var/folders/"* ]] || [[ $TMPDIR == "" ]]; then
export TMPDIR="/tmp/user-$USER"
mkdir -p "$TMPDIR"
fi

View File

@@ -1,2 +0,0 @@
cache/*
repos/*

View File

@@ -1,65 +0,0 @@
#
# Z-Shell Init
#
# Basic stuff.
DISABLE_AUTO_TITLE="true"
# Export path variables.
DOTZSH="$DOTSHELL/zsh"
ZPLUG_HOME="$DOTZSH/zplug"
ZPLUG_CACHE_DIR="$DOTZSH/zplug-cache/cache"
ZPLUG_REPOS="$DOTZSH/zplug-cache/repos"
# Don't wrap these commands in a Bundler wrapper.
UNBUNDLED_COMMANDS=(shotgun)
#
# zplug
#
source "$DOTZSH/zplug/init.zsh"
alias zp="zplug"
zplug "lib/history", from:oh-my-zsh, defer:0
zplug "jimeh/zsh-peco-history", defer:2
zplug "plugins/bundler", from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh
zplug "zsh-users/zsh-completions"
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-syntax-highlighting", defer:3
zplug "jimeh/plain.zsh-theme", as:theme
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo
zplug install
fi
fi
# Configure zsh-syntax-highlighting
if zplug check zsh-users/zsh-syntax-highlighting; then
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
fi
zplug load
#
# Basic Z-Shell settings
#
# Enable bash-style completion.
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit
# Disable shared history.
unsetopt share_history
# Disable attempted correction of commands (is wrong 98% of the time).
unsetopt correctall
# Cause I hit emacs shorts too much.
# bindkey -s "\C-x\C-f" "cd "

View File

@@ -1,24 +0,0 @@
#
# Shell Init
#
# Set path to root of dotfiles
if [ -n "${BASH_SOURCE[0]}" ] && [ -f "${BASH_SOURCE[0]}" ] ; then
DOTFILES="`dirname \"${BASH_SOURCE[0]}\"`"
elif [ -n "$0" ] && [ -f "$0" ]; then
DOTFILES="`dirname \"$0\"`"
elif [ -d "$HOME/.dotfiles" ]; then
DOTFILES="$HOME/.dotfiles"
fi
# Load main dotfiles
DOTSHELL="$DOTFILES/shell"
if [ -f "$DOTSHELL/_main.sh" ]; then
source "$DOTSHELL/_main.sh"
fi
# Setup and load private dotfiles
DOTPFILES="$DOTFILES/private"
if [ -f "$DOTPFILES/shellrc.sh" ]; then
source "$DOTPFILES/shellrc.sh"
fi

8
zsh/linux.zsh Normal file
View File

@@ -0,0 +1,8 @@
#
# Linux specific setup
#
# Ensure 256 color support in Linux
if [[ "$(uname)" == "Linux" ]]; then
export TERM="xterm-256color"
fi

41
zsh/osx.zsh Normal file
View File

@@ -0,0 +1,41 @@
#
# OSX Related
#
if [[ "$(uname)" == "Darwin" ]]; then
# 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 \
'<dict><key>enabled</key><false/></dict>'
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
}
fi

View File

@@ -16,13 +16,14 @@ if [ -f "/usr/local/etc/bash_completion.d/tmux" ]; then
fi
# Tmuxifier
if [ -d "$DOTSHELL/tmux/tmuxifier" ]; then
if [ -d "$HOME/.dotfiles/private/tmux-layouts" ]; then
export TMUXIFIER_LAYOUT_PATH="$HOME/.dotfiles/private/tmux-layouts"
if [ -d "$DOTFILES/tmux/tmuxifier" ]; then
if [ -d "$DOTPFILES/tmux-layouts" ]; then
export TMUXIFIER_LAYOUT_PATH="$DOTPFILES/tmux-layouts"
else
export TMUXIFIER_LAYOUT_PATH="$HOME/.tmux-layouts"
fi
path_prepend "$DOTSHELL/tmux/tmuxifier/bin"
path_prepend "$DOTFILES/tmux/tmuxifier/bin"
eval "$(tmuxifier init -)"
alias m="tmuxifier"
@@ -33,6 +34,6 @@ fi
use-tmuxifier-dev() {
path_prepend "$HOME/Projects/tmuxifier/bin"
path_remove "$DOTSHELL/tmux/tmuxifier/bin"
path_remove "$DOTFILES/tmux/tmuxifier/bin"
export TMUXIFIER="$HOME/Projects/tmuxifier"
}

134
zshrc.zsh Normal file
View File

@@ -0,0 +1,134 @@
#
# Z-Shell Init
#
if [ -n "$0" ] && [ -f "$0" ]; then
DOTFILES="`dirname \"$0\"`"
elif [ -d "$HOME/.dotfiles" ]; then
DOTFILES="$HOME/.dotfiles"
fi
# ==============================================================================
# Environment variables
# ==============================================================================
# Export path variables.
DOTPFILES="$DOTFILES/private"
DOTBIN="$DOTFILES/bin"
DOTZSH="$DOTFILES/zsh"
# Path helpers.
source "$DOTZSH/path_helpers.zsh"
# Ensure /usr/local/bin is before various system-paths
path_prepend "/usr/local/bin"
# Editors
export EDITOR="emacsclient-wrapper"
export GEM_EDITOR="mate"
# Locale Setup
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
# ensure bin and sbin paths from /usr/local are in PATH
path_add_after "/usr/local/sbin" "/usr/local/bin"
# ensure bin and sbin paths from /usr are in PATH
path_add_after "/usr/sbin" "/usr/bin"
# Add user's bin directory to PATH
path_prepend "$HOME/bin"
# Add dotfiles' bin directory to PATH
path_prepend "$DOTBIN"
# Ensure TMPDIR is the same for local and remote ssh logins
if [[ $TMPDIR == "/var/folders/"* ]] || [[ $TMPDIR == "" ]]; then
export TMPDIR="/tmp/user-$USER"
mkdir -p "$TMPDIR"
fi
# ==============================================================================
# Basic Z-Shell settings
# ==============================================================================
# Disable auto-title.
DISABLE_AUTO_TITLE="true"
# Enable bash-style completion.
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit
# Disable shared history.
unsetopt share_history
# Disable attempted correction of commands (is wrong 98% of the time).
unsetopt correctall
# ==============================================================================
# zplug
# ==============================================================================
ZPLUG_HOME="$DOTZSH/zplug/zplug"
ZPLUG_CACHE_DIR="$DOTZSH/zplug/cache"
ZPLUG_REPOS="$DOTZSH/zplug/repos"
source "$ZPLUG_HOME/init.zsh"
alias zp="zplug"
zplug "lib/history", from:oh-my-zsh, defer:1
zplug "jimeh/zsh-peco-history", defer:2
zplug "plugins/bundler", from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh
zplug "zsh-users/zsh-completions"
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-syntax-highlighting", defer:3
zplug "jimeh/plain.zsh-theme", as:theme
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo
zplug install
fi
fi
# Configure zsh-syntax-highlighting
if zplug check zsh-users/zsh-syntax-highlighting; then
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
fi
zplug load
# ==============================================================================
# Load custom scripts
# ==============================================================================
# Aliases
source "$DOTZSH/aliases.zsh"
# OS specific
source "$DOTZSH/osx.zsh"
source "$DOTZSH/linux.zsh"
# Utils
source "$DOTZSH/emacs.zsh"
source "$DOTZSH/git.zsh"
source "$DOTZSH/tmux.zsh"
source "$DOTZSH/less.zsh"
# Development
source "$DOTZSH/nodejs.zsh"
source "$DOTZSH/ruby.zsh"
source "$DOTZSH/rust.zsh"
source "$DOTZSH/golang.zsh"
source "$DOTZSH/docker.zsh"
source "$DOTZSH/google-cloud.zsh"
source "$DOTZSH/kubernetes.zsh"
if [ -f "$DOTPFILES/shellrc.sh" ]; then
source "$DOTPFILES/shellrc.sh"
fi