Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Suggestion for auto install script #395

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants

tombh commented Feb 18, 2013

No description provided.

@ColinHebert ColinHebert commented on the diff Feb 18, 2013

install.sh
@@ -0,0 +1,47 @@
+home_dir=${ZDOTDIR:-$HOME}
@ColinHebert

ColinHebert Feb 18, 2013

Contributor

If it's a sh file a shebang would be appropriate

@tombh

tombh Feb 19, 2013

So that it could be run from the command line with, `./install.sh'? Would we then need to change the executable flag on it too?

@ColinHebert

ColinHebert Feb 19, 2013

Contributor

I think that could be a good thing. And if you remove the condition on line 9 (check if the prezto directory is already present), it would allow people to git clone the project in their .prezto folder and launch the installer from there (to have the .zshrc, etc. backuped/copied).

@tombh

tombh Feb 19, 2013

Here's a clever idea, what if we detected if the script was run via shebang or pipe? This works on my system;

#!/bin/zsh
if [ -n "$1" ]; then
  exec <"$1"
elif tty >/dev/null; then
  echo 'file'
else
  echo "pipe"
fi

Then if the script is run via shebang we can assume it's already installed and just do the linking of the rc files.

@ColinHebert ColinHebert commented on the diff Feb 18, 2013

install.sh
@@ -0,0 +1,47 @@
+home_dir=${ZDOTDIR:-$HOME}
+prezto_dir="$home_dir/.zprezto"
+
+hash zsh 2>/dev/null || {
@ColinHebert

ColinHebert Feb 18, 2013

Contributor

If we're already in a ZSH, there is probably no need to check that.

@tombh

tombh Feb 19, 2013

So, this script could be installed over curl (ie piped into zsh), or ran from the command, ran directly in bash, in which case someone may not have installed zsh yet.

@ColinHebert ColinHebert commented on the diff Feb 18, 2013

install.sh
+ echo "Linking $rcfile to $dest"
+ ln -s $rcfile $dest
+done
+
+echo ""
+echo "Copying your current PATH and adding it to the end of ~/.zshrc"
+echo "export PATH=$PATH" >> ~/.zshrc
+
+
+echo ""
+echo "You can ensure $USER's default shell is set to zsh with 'chsh -s \`which zsh\`'"
+
+echo ""
+echo "Prezto is now installed. Login into, or reload zsh to activate."
+
+echo ""
@ColinHebert

ColinHebert Feb 18, 2013

Contributor

An empty line is missing here

@tombh

tombh Feb 19, 2013

Good point :)

@ColinHebert ColinHebert commented on the diff Feb 19, 2013

install.sh
+prezto_dir="$home_dir/.zprezto"
+
+hash zsh 2>/dev/null || {
+ echo "Zsh, isn't installed on your system, you're going to need to install that first."
+ exit 1
+}
+
+if [ -d $prezto_dir ]
+then
+ echo "Prezto already installed, exiting installation."
+ exit
+fi
+
+echo ""
+echo "Git cloning Prezto into $prezto_dir"
+hash git 2>/dev/null && /usr/bin/env git clone --recursive https://github.com/sorin-ionescu/prezto.git $prezto_dir || {
@ColinHebert

ColinHebert Feb 19, 2013

Contributor

I think that we should provide a way to install prezto even if git isn't present.
What about using a tarball ( https://github.com/sorin-ionescu/prezto/archive/master.zip well a zipball but you got the idea).

@tombh

tombh Feb 19, 2013

Excellent idea!

@ColinHebert

ColinHebert Feb 19, 2013

Contributor

Actually https://github.com/sorin-ionescu/prezto/archive/master.tar.gz also works (no need to use unzip \o/)

@ColinHebert ColinHebert commented on the diff Feb 19, 2013

install.sh
+setopt EXTENDED_GLOB
+for rcfile in "$home_dir"/.zprezto/runcoms/^README.md(.N); do
+ dest="$home_dir/.${rcfile:t}"
+ if [ -f $dest ] || [ -h $dest ]
+ then
+ backup="$dest.prezto_backup"
+ echo "Backing up $dest to $backup"
+ mv $dest $backup
+ fi
+ echo "Linking $rcfile to $dest"
+ ln -s $rcfile $dest
+done
+
+echo ""
+echo "Copying your current PATH and adding it to the end of ~/.zshrc"
+echo "export PATH=$PATH" >> ~/.zshrc
@ColinHebert

ColinHebert Feb 19, 2013

Contributor

It might be like a good idea, but it could lead to some confusion regarding the path.
I don't have a specific opinion on that, but I think it should be raised.

@tombh

tombh Feb 19, 2013

I saw this in OMZ's installers, let's just get rid of it.

Owner

sorin-ionescu commented Feb 28, 2013

Thanks for attempting to implement #231. I think it should be in a gist though.

tombh commented Mar 1, 2013

That's fine, I understand. May I suggest that you at least amend the README to highlight the importance of sourcing init.zsh?

@tombh tombh closed this Mar 1, 2013

Owner

sorin-ionescu commented Mar 1, 2013

What do you mean? init.zsh is being sourced.

Contributor

ColinHebert commented Mar 5, 2013

@sorin-ionescu What would be the advantage of putting it in a gist rather than having having it in the repo?

I can see an advantage of it being in the repo, if you clone your repo before-hand you can launch the script from the source you've just downloaded.

tombh commented Mar 5, 2013

Personally, I think having it in the repo is more to do with publicising a canonical method of installation that the most possible people will be exposed to.

Owner

sorin-ionescu commented Mar 5, 2013

The installation script is not for those who clone the repo, but for those who just want to copy/paste curl -s /path/to/gist | zsh.

Contributor

ColinHebert commented Mar 5, 2013

@sorin-ionescu It would be curl -L https://github.com/sorin-ionescu/prezto/raw/install_script/install.sh | zsh, I mean besides the fact that it's not a gist, it will still work the same way.

Contributor

ColinHebert commented Mar 5, 2013

And if the script ever needs to be modified, it will be easily accessible (within the repo) and still available at the exact same URL.

tombh commented Mar 5, 2013

And it can have Pull Requests made against and it will have much more of an official status, meaning more people will use and potentially improve on it.

Owner

sorin-ionescu commented Mar 5, 2013

Gists can have revisions, comments, as well as forks. All forks are easily accessible. That said, any installation script ought to be accompanied by an uninstallation script.

Contributor

ColinHebert commented Mar 5, 2013

Even if gist support that I'm not sure I see the benefit of a gist.

Regarding the installation/uninstallation script, I'm not so sure that's true, but you raise a good point, we don't have any instruction on how to remove prezto once it's there. I think we should have an uninstall.md (or something similar) which explains how to remove prezto the right way (which is basically removing the .prezto dir and the sourcing of init.zsh).

@kodelint kodelint pushed a commit to kodelint/prezto that referenced this pull request Nov 15, 2016

@nicoulaj nicoulaj Merge pull request #395 from JindrichPilar/dad
Completion for dad added
a38ddf9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment