From 759652523bda1c0a0c32fe839c627a14421cfa19 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Wed, 3 Aug 2016 15:47:40 -0500 Subject: [PATCH] Adding cygwin patches --- home/.zshrc | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/home/.zshrc b/home/.zshrc index 929c0bd..f27200e 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -5,6 +5,12 @@ export ZSH=$HOME/.oh-my-zsh +# Detect if we're running in cygwin +local cygwin="$(env | grep cygdrive &>/dev/null && echo $?)" +if [ -n "${cygwin}" ] && [[ "${cygwin}" == "0" ]]; then + export CSYSTEM="CSYS" +fi + # Best theme ever! ZSH_THEME="ys" @@ -77,8 +83,31 @@ if [ -d "$HOME/.rbenv" ] && [ -z "$MSYSTEM" ]; then eval "$(rbenv init -)" fi +# A function that does the automatic path translation for a windows emacs +cygwin_emacsclient(){ + # Loop over all the input variables and convert their paths + declare -a args=() + for arg in $@ + do + win_path="$(cygpath -p -w $arg)" + args=("${args[@]}" "${win_path}") + done + # Execute emacsclient with the correct paths + emacsclient -a vim $args[@] +} + +# Cygwin Specific Configuration +if [ -n "${CSYSTEM}" ] && [[ "${CSYSTEM}" == "CSYS" ]]; then + # Configure emacsclient to get the correct paths + emacs_path="$(which emacs)" + if [[ $emacs_path == /cygdrive* ]]; then + alias ec=cygwin_emacsclient + fi + +fi + # MSYS Specific Configuration -if [ ! -z "$MSYSTEM" ] && [[ "$MSYSTEM" == "MSYS" ]]; then +if [ -n "$MSYSTEM" ] && [[ "$MSYSTEM" == "MSYS" ]]; then # Make sure msys has our CL on the path export PATH=$(append_if_exists $PATH ":" $(dirname "$CL_BIN")) fi