From 49f1bba89cda3f9c2618678254bdb08de11af428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 00:02:40 +0100 Subject: [PATCH 01/11] Ask user to perform or not a full system update --- matjaz_dotfiles_installer.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/matjaz_dotfiles_installer.sh b/matjaz_dotfiles_installer.sh index 08b53d6..5c962bf 100755 --- a/matjaz_dotfiles_installer.sh +++ b/matjaz_dotfiles_installer.sh @@ -106,10 +106,13 @@ if [ -e ~/.zshrc.pre-oh-my-zsh ]; then mv ~/.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 + printf "You can peform it manually by launching + bash %sfull_system_updater.sh\n" $dotfiles_dir +fi # Clean some variables unset backup_dir From 9cd686161bc20990aca9a36527e9c22eddb0732f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 00:02:54 +0100 Subject: [PATCH 02/11] Make the installer switch to zsh at the end --- matjaz_dotfiles_installer.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/matjaz_dotfiles_installer.sh b/matjaz_dotfiles_installer.sh index 5c962bf..ae4f12c 100755 --- a/matjaz_dotfiles_installer.sh +++ b/matjaz_dotfiles_installer.sh @@ -118,3 +118,5 @@ fi unset backup_dir unset dotfiles_dir +echo "Switching to zsh" +env zsh From 2bf97e964fc653e44a0dfa2c3ac17eaf09a4c218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 00:03:22 +0100 Subject: [PATCH 03/11] Make zsh_path portable also for OS without brew command --- zsh_path | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh_path b/zsh_path index b0c9ed6..dfdd483 100644 --- a/zsh_path +++ b/zsh_path @@ -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" From 28af79765c90c4980a53a8d30b4e24fd0b030000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 00:03:45 +0100 Subject: [PATCH 04/11] Fix non-portable home directory in zshrc --- zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zshrc b/zshrc index 84cf055..e1a3094 100644 --- a/zshrc +++ b/zshrc @@ -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/ From 69e3cc3a92fac1be624dd31bf32ba61fc21e1cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 00:04:55 +0100 Subject: [PATCH 05/11] Install zsh-syntax-highlight as Oh My ZSH plugin with git clone/pull The repo of the plugin gets cloned if not existing or just updated by git pull if already exists. The plugin is activated in zshrc. --- matjaz_dotfiles_installer.sh | 1 + new_system_packages_installer.sh | 17 ++++++++++++++++- zshrc | 4 +--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/matjaz_dotfiles_installer.sh b/matjaz_dotfiles_installer.sh index ae4f12c..31c3248 100755 --- a/matjaz_dotfiles_installer.sh +++ b/matjaz_dotfiles_installer.sh @@ -52,6 +52,7 @@ fi # Install a set of basic packages on newly set systems, along with Oh My ZSH! 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 diff --git a/new_system_packages_installer.sh b/new_system_packages_installer.sh index b2286ff..b0bc5e6 100755 --- a/new_system_packages_installer.sh +++ b/new_system_packages_installer.sh @@ -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 @@ -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 diff --git a/zshrc b/zshrc index e1a3094..c8ca9f9 100644 --- a/zshrc +++ b/zshrc @@ -81,6 +81,7 @@ plugins=( # copydir # compleat # autojump + zsh-syntax-highlighting # must be the last one ) @@ -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 From 98857abd393d0eab0891e03820a56e9a84e5682f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 00:09:29 +0100 Subject: [PATCH 06/11] Add v1.0.1 to changelog --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e46b1dc..a743aad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ====== From 31c4ad2adc2edbb62d4b5cf7e966dcf5a2af6a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 00:16:32 +0100 Subject: [PATCH 07/11] Change $HOME to ~ --- matjaz_dotfiles_installer.sh | 2 +- new_system_packages_installer.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/matjaz_dotfiles_installer.sh b/matjaz_dotfiles_installer.sh index 31c3248..fb828b0 100755 --- a/matjaz_dotfiles_installer.sh +++ b/matjaz_dotfiles_installer.sh @@ -33,7 +33,7 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then fi # Create dotfiles directory and clone repository into it -dotfiles_dir="$HOME/Development/Dotfiles/" +dotfiles_dir="~/Development/Dotfiles/" backup_dir="$dotfiles_dir.original_dotfiles/" mkdir -p $dotfiles_dir cd $dotfiles_dir diff --git a/new_system_packages_installer.sh b/new_system_packages_installer.sh index b0bc5e6..89b1ca5 100755 --- a/new_system_packages_installer.sh +++ b/new_system_packages_installer.sh @@ -77,7 +77,7 @@ else fi # Install the live syntax highlighting for Oh My ZSH -zshsyntax_dir="$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" +zshsyntax_dir="~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" if [ -d $zshsyntax_dir/.git ]; then echo "Updating existing zsh-syntax-highlighting repository." cd $zshsyntax_dir From f5d608d2bb7eceb62af1d364949e87f92fa66278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 00:20:02 +0100 Subject: [PATCH 08/11] Fix question for full system update --- matjaz_dotfiles_installer.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matjaz_dotfiles_installer.sh b/matjaz_dotfiles_installer.sh index fb828b0..f5c1c0e 100755 --- a/matjaz_dotfiles_installer.sh +++ b/matjaz_dotfiles_installer.sh @@ -110,7 +110,9 @@ fi 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 +if [[ $REPLY =~ ^[Yy]$ ]]; then + bash $dotfiles_dir"full_system_updater.sh" +else printf "You can peform it manually by launching bash %sfull_system_updater.sh\n" $dotfiles_dir fi From 748b6a56482b5491a9e2be2e77365937a7a9ff74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 01:00:39 +0100 Subject: [PATCH 09/11] Fix: change back ~ to $HOME, fix string concatenation using "~" as home directory led to creation of a local ".\~" directory. --- matjaz_dotfiles_installer.sh | 14 +++++++------- new_system_packages_installer.sh | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/matjaz_dotfiles_installer.sh b/matjaz_dotfiles_installer.sh index f5c1c0e..47abe86 100755 --- a/matjaz_dotfiles_installer.sh +++ b/matjaz_dotfiles_installer.sh @@ -33,13 +33,13 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then fi # Create dotfiles directory and clone repository into it -dotfiles_dir="~/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." @@ -51,7 +51,7 @@ 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 @@ -111,7 +111,7 @@ 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" + bash "$dotfiles_dir""full_system_updater.sh" else printf "You can peform it manually by launching bash %sfull_system_updater.sh\n" $dotfiles_dir diff --git a/new_system_packages_installer.sh b/new_system_packages_installer.sh index 89b1ca5..569fb43 100755 --- a/new_system_packages_installer.sh +++ b/new_system_packages_installer.sh @@ -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 @@ -77,7 +77,7 @@ else fi # Install the live syntax highlighting for Oh My ZSH -zshsyntax_dir="~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" +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 From e4993d5f43b6cdf8f0442c577939a17299e73913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 01:14:37 +0100 Subject: [PATCH 10/11] Forced $HOME again everywhere, changed string concatenation Now $dotfiles_dir has no ending slash and the slash is used to concatenate better --- matjaz_dotfiles_installer.sh | 52 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/matjaz_dotfiles_installer.sh b/matjaz_dotfiles_installer.sh index 47abe86..afc78fe 100755 --- a/matjaz_dotfiles_installer.sh +++ b/matjaz_dotfiles_installer.sh @@ -33,11 +33,11 @@ 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 echo "Dotfiles are stored in $dotfiles_dir" -if [ -d "$dotfiles_dir"".git" ]; then +if [ -d $dotfiles_dir/.git ]; then echo "Updating existing dotfiles repository." cd $dotfiles_dir git pull @@ -51,15 +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" @@ -71,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. @@ -101,20 +101,20 @@ 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 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" + bash $dotfiles_dir/full_system_updater.sh else - printf "You can peform it manually by launching - bash %sfull_system_updater.sh\n" $dotfiles_dir + echo "You can peform it manually by launching + bash $dotfiles_dir/full_system_updater.sh" fi # Clean some variables From a5bc0c1f65bf2998cdeb4868e358cc166296ce7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matjaz=CC=8C?= Date: Thu, 26 Nov 2015 01:21:22 +0100 Subject: [PATCH 11/11] Delete strange file "1" at end of script, return to home directory --- matjaz_dotfiles_installer.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/matjaz_dotfiles_installer.sh b/matjaz_dotfiles_installer.sh index afc78fe..0182805 100755 --- a/matjaz_dotfiles_installer.sh +++ b/matjaz_dotfiles_installer.sh @@ -120,6 +120,8 @@ fi # Clean some variables unset backup_dir unset dotfiles_dir +rm $dotfiles_dir/1 echo "Switching to zsh" +cd env zsh