Skip to content

Commit

Permalink
v1.0.1: portability fixes, general fixes and user friendliness
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMatjaz committed Nov 26, 2015
2 parents b8c7863 + a5bc0c1 commit d1c496b
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 36 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
v1.0.1
======

Fixed
-----

- Portability fixes:
-`zsh_path` is now portable also on non-OS X systems
- Fix non portable home directory in `zshrc`
- Fix non portable `zsh-syntax-highlight` Oh My ZSH plugin
- Ask user to perform or not the full system update of package managers
- Installer switches to zsh at the end of execution


v1.0.0
======

Expand Down
68 changes: 39 additions & 29 deletions matjaz_dotfiles_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
fi

# Create dotfiles directory and clone repository into it
dotfiles_dir="$HOME/Development/Dotfiles/"
backup_dir="$dotfiles_dir.original_dotfiles/"
dotfiles_dir="$HOME/Development/Dotfiles"
backup_dir="$dotfiles_dir/.original_dotfiles/"
mkdir -p $dotfiles_dir
cd $dotfiles_dir
echo "A folder $dotfiles_dir has been created to store all the dotfiles in it."
if [ -d .git ]; then
echo "Dotfiles are stored in $dotfiles_dir"
if [ -d $dotfiles_dir/.git ]; then
echo "Updating existing dotfiles repository."
cd $dotfiles_dir
git pull
else
echo "Cloning the dotfiles repository."
Expand All @@ -51,14 +51,15 @@ Please try running this script again."
fi

# Install a set of basic packages on newly set systems, along with Oh My ZSH!
bash $dotfiles_dir"new_system_packages_installer.sh"
bash $dotfiles_dir/new_system_packages_installer.sh
cd $dotfiles_dir

# Creates a symbolic link to the file specified in the first argument $1
# pointing to the file specified in the second argument $2. Backups any existing
# file at the position $2 to the backup directory.
function symlink_dotfile() {
local file_in_repo=$dotfiles_dir$1
local file_in_home=$2
local file_in_repo=$dotfiles_dir/$1
local file_in_home=$HOME/$2
if [[ -e $file_in_home && ! -L $file_in_home ]]; then
mkdir -p $backup_dir # prepare backup directory if not exists
echo "Backing up existing $file_in_home into $backup_dir"
Expand All @@ -70,28 +71,28 @@ function symlink_dotfile() {
# Create symlinks in the home directory that point to the files in the
# dotfiles repository. Any existing dotfiles get backupped.
echo "Symlinking..."
symlink_dotfile gitconfig ~/.gitconfig
symlink_dotfile gitignore_global ~/.gitignore_global
symlink_dotfile hgrc ~/.hgrc
symlink_dotfile screenrc ~/.screenrc
symlink_dotfile wgetrc ~/.wgetrc
mkdir -p ~/.oh-my-zsh/custom/themes/ # it does not exist by default
symlink_dotfile zsh_fino_custom.zsh-theme ~/.oh-my-zsh/custom/themes/zsh_fino_custom.zsh-theme
symlink_dotfile zsh_aliases ~/.zsh_aliases
symlink_dotfile zsh_path ~/.zsh_path
symlink_dotfile zshrc ~/.zshrc
symlink_dotfile mc_ini ~/.config/mc/ini
symlink_dotfile mc_panels.ini ~/.config/mc/panels.ini
symlink_dotfile emacs_init.el ~/.emacs.d/init.el
symlink_dotfile gitconfig .gitconfig
symlink_dotfile gitignore_global .gitignore_global
symlink_dotfile hgrc .hgrc
symlink_dotfile screenrc .screenrc
symlink_dotfile wgetrc .wgetrc
mkdir -p $HOME/.oh-my-zsh/custom/themes/ # it does not exist by default
symlink_dotfile zsh_fino_custom.zsh-theme .oh-my-zsh/custom/themes/zsh_fino_custom.zsh-theme
symlink_dotfile zsh_aliases .zsh_aliases
symlink_dotfile zsh_path .zsh_path
symlink_dotfile zshrc .zshrc
symlink_dotfile mc_ini .config/mc/ini
symlink_dotfile mc_panels.ini .config/mc/panels.ini
symlink_dotfile emacs_init.el .emacs.d/init.el

# Symlink the htop configuration file as well, but place it in ~/.htoprc on Macs
# and in ~/.config/htop/htoprc on Linux.
case $(uname) in
'Darwin')
symlink_dotfile htoprc ~/.htoprc
symlink_dotfile htoprc .htoprc
;;
'Linux')
symlink_dotfile htoprc ~/.config/htop/htoprc
symlink_dotfile htoprc .config/htop/htoprc
;;
*)
echo "Cannot symlink htoprc on proper position on this operative system.
Expand All @@ -100,18 +101,27 @@ Please update this script $(basename $0) or perform the symlink manually."
esac

# Move backup made by Oh My ZSH installer to $backup_dir
if [ -e ~/.zshrc.pre-oh-my-zsh ]; then
if [ -e $HOME/.zshrc.pre-oh-my-zsh ]; then
echo "Moved old zshrc backupped by Oh My ZSH to $backup_dir"
mkdir -p $backup_dir
mv ~/.zshrc.pre-oh-my-zsh $backup_dir
mv $HOME/.zshrc.pre-oh-my-zsh $backup_dir
fi

printf "Completed.
A full update of the system is suggested. Launch it with
bash %sfull_system_updater.sh
" $dotfiles_dir
echo "Dotfiles installation completed."
read -p "Do you want to perform an update+upgrade of all package managers? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
bash $dotfiles_dir/full_system_updater.sh
else
echo "You can peform it manually by launching
bash $dotfiles_dir/full_system_updater.sh"
fi

# Clean some variables
unset backup_dir
unset dotfiles_dir
rm $dotfiles_dir/1

echo "Switching to zsh"
cd
env zsh
19 changes: 17 additions & 2 deletions new_system_packages_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ case $(uname) in
else
echo "Homebrew already installed, skipping installation."
fi
echo "Updating Homebrew local repository..."
echo "Updating Homebrew local repository."
brew update
echo "Installing the packages."
brew install brew-cask emacs git git-flow htop-osx midnight-commander python3 sqlite wget
Expand Down Expand Up @@ -66,7 +66,7 @@ Please update this script $(basename $0)"
esac

# Install Oh My ZSH if not already installed
if [ -d ~/.oh-my-zsh ]; then
if [ -d $HOME/.oh-my-zsh ]; then
echo "Oh My ZSH installation found, skipping install."
else
# Download and run Oh My ZSH installer without letting them enter the zsh
Expand All @@ -75,3 +75,18 @@ else
echo "It may ask you for a password to set zsh as default shell:"
sudo chsh -s $(which zsh)
fi

# Install the live syntax highlighting for Oh My ZSH
zshsyntax_dir="$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
if [ -d $zshsyntax_dir/.git ]; then
echo "Updating existing zsh-syntax-highlighting repository."
cd $zshsyntax_dir
git pull
else
echo "Cloning the zsh-syntax-highlighting repository."
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git $zshsyntax_dir || {
echo "An error occurred during the cloning of the zsh-syntax-highlighting repository.
Please try running this script again."
exit 1
}
fi
2 changes: 1 addition & 1 deletion zsh_path
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ===================
# Including: Homebrew Cellar, X11, MacGPG, TeX, PostgreSQL (psql), SQLite3
# (from Homebrew), RVM
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/usr/texbin:/Applications/Postgres.app/Contents/Versions/9.4/bin:$(brew --prefix sqlite)/bin:~/.rvm/bin"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/MacGPG2/bin:/usr/texbin:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/local/opt/sqlite:~/.rvm/bin"
# export MANPATH="/usr/local/man:$MANPATH"


Expand Down
6 changes: 2 additions & 4 deletions zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# ===================
#
# Path to your oh-my-zsh installation.
export ZSH=/Users/matjaz/.oh-my-zsh
export ZSH=~/.oh-my-zsh

# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
Expand Down Expand Up @@ -81,6 +81,7 @@ plugins=(
# copydir
# compleat
# autojump
zsh-syntax-highlighting # must be the last one
)


Expand All @@ -98,9 +99,6 @@ source ~/.zsh_path
# ssh
# export SSH_KEY_PATH="~/.ssh/dsa_id"

# enable zsh-syntax-highlighting installed from Homebrew
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# ALIASES
# =======
source ~/.zsh_aliases

0 comments on commit d1c496b

Please sign in to comment.