-
Notifications
You must be signed in to change notification settings - Fork 57
/
zsh.sh
executable file
·104 lines (88 loc) · 3.27 KB
/
zsh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# This script is intended to setup a fresh desktop with ROS and
# with dependencies on homebrew or linuxbrew depending on the OS being used
# @author Andrew Hundt <ATHundt@gmail.com>
echo ""
echo "###############################################################################################"
echo "# ZSH https://en.wikipedia.org/wiki/Z_shell setup and config"
echo "# using Prezto https://github.com/sorin-ionescu/prezto"
echo "###############################################################################################"
echo "#"
echo "# Installs zsh if necessary, sets it as the default shell,"
echo "# and enables a reasonable default configuration using Prezto"
echo "#"
echo "# Prezto — Instantly Awesome Zsh configuration framework"
echo "# https://github.com/sorin-ionescu/prezto"
echo "# Updating zsh's prezto configuration"
echo "# Pull the latest changes and update submodules."
echo "# "
echo "# cd ~/.zprezto && git pull && git submodule update --init --recursive"
echo "# "
echo "# This also enables the use of robotics_setup/.robotics_setup to configure your system"
echo "# to work with the other robotics_setup *.sh package install scripts you run."
echo ""
# source: https://gist.github.com/phatblat/1713458
# Save script's current directory
DIR=$(pwd)
# /bin/bash
set -e
set -u
set -x
cd ~
# prezto tools to make zsh life easier
# https://github.com/sorin-ionescu/prezto
# found via os x setup guide
# http://sourabhbajaj.com/mac-setup/iTerm/zsh.html
# check if homebrew is installed
# in that case use it to install zsh
# if needed
if [ -x "$(command -v zsh)" ] ; then
# we don't have zsh, try to install it...
if [ -x "$(command -v brew)" ] ; then
# if homebrew/linuxbrew is installed use that to install zsh
brew install zsh zsh-completions
elif [ -x "$(command -v apt-get)" ] ; then
# if apt-get exists use that to install zsh
sudo apt-get install -y zsh
fi
fi
if [ ! -f `pwd`/.zshrc ] ; then
cp $DIR/.zshrc ~/.zshrc
# sometimes you can't run chsh...
if [ -x "$(command -v ypchsh)" ] ; then
echo "TODO(ahundt) fix chsh... doesn't work on this platform right now... see robotics_setup/README.md"
#ypchsh -s $(which zsh)
else
chsh -s $(which zsh)
fi
fi
# create prezto symlinks to configure zsh
if [ ! -f $HOME/.zpreztorc ] ; then
ln -s $DIR/.zpreztorc ~/.zpreztorc
fi
if [ ! -f $HOME/.zshrc ] ; then
ln -s $DIR/.zshrc ~/.zshrc
fi
# symlink so robotics_setup config is always up to date
if [ ! -f $HOME/.robotics_setup ] ; then
ln -s $DIR/.robotics_setup $HOME/.robotics_setup
fi
# only run zsh commands if zsh exists
if [ -x "$(command -v zsh)" ] ; then
if [ ! -d ~/.zprezto ] ; then
zsh -c "git clone --recursive https://github.com/sorin-ionescu/prezto.git \"${ZDOTDIR:-$HOME}/.zprezto\""
fi
# adapted from https://github.com/sorin-ionescu/prezto
# creates symlinks to all prezto files not provided by robotics_setup
# see https://github.com/sorin-ionescu/prezto/tree/master/runcoms for details
cd $DIR
zsh zshpreztolinks.zsh
# zsh -c "setopt EXTENDED_GLOB;
# rcfiles=\"${ZDOTDIR:-$HOME}\"/.zprezto/runcoms/^README.md(.N)
# echo $rcfiles
# for rcfile in rcfiles; do
# if [ ! -f \"$rcfile\" ] ; then
# ln -s \"$rcfile\" \"${ZDOTDIR:-$HOME}/.${rcfile:t}\";
# fi
# done"
fi