Commit cfe8e769 authored by Stephen M. Coakley's avatar Stephen M. Coakley Committed by GitHub

Refactor installer and config setup (#361)

Refactor the installer to be more maintainable and interactive. The installer is now more robust and safe in its operation, and asks interactive questions for choices that the user must resolve. Setting up confuguration is also now changed to take advantage of Fish 2.3 features and does not mess with user's configuration files without permission.

- Make installer smarter and use uninstaller in destroy
- Better handling and checking for offline installs
- `omf destroy` simply uses `install --uninstall`
- Final warning message is no longer displayed when user intentionally aborts install
- Backups are restored during uninstall
- Update the README to detail the new ways to install OMF
parent 48ace421
......@@ -17,13 +17,14 @@ addons:
- tree
before_install:
- tools/travis-install-git.sh
- source tools/travis-github-pr-integration.sh
- tools/travis-install-fish.sh
before_script:
- tree -h
- export
- fish $TRAVIS_BUILD_DIR/bin/install
- fish $TRAVIS_BUILD_DIR/bin/install --offline --noninteractive --yes
script:
- tests/run.fish
......
FROM ohmyfish/fish:2.2.0
FROM ohmyfish/fish:2.3.0
COPY . /src/oh-my-fish
# Prevent install from opening a new fish shell
ENV CI WORKAROUND
# Replace this when offline installation is supported
ARG OMF_REPO_BRANCH=master
ARG OMF_REPO_URI=https://github.com/oh-my-fish/oh-my-fish
RUN fish /src/oh-my-fish/bin/install
RUN fish /src/oh-my-fish/bin/install --offline --noninteractive --yes
WORKDIR /root/.local/share/omf
......@@ -16,19 +16,34 @@ Oh My Fish provides core infrastructure to allow you to install packages which e
## Installation
You can get started right away with the default setup by running this in your terminal:
```fish
curl -L http://get.oh-my.fish | fish
```
This will download the installer script and start the installation. Alternatively, you can download the installer and customize your install:
```fish
curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install | fish
omf help
curl -L http://get.oh-my.fish > install
fish install --path=data/oh-my-fish --config=$HOME/.my-omf-config
```
Or _download_ and run it yourself:
You can also install Oh My Fish with Git or with an offline source tarball downloaded from the [releases page][releases]:
```fish
curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/bin/install > install
fish install
# with git
$ git clone https://github.com/oh-my-fish/oh-my-fish
$ cd oh-my-fish
$ bin/install --offline
# with a tarball
$ curl -L http://get.oh-my.fish > install
$ fish install --offline=omf.tar.gz
```
# Getting Started
Run `install --help` for a complete list of install options you can customize.
## Getting Started
Oh My Fish includes a small utility `omf` to fetch and install new packages and themes.
......@@ -126,10 +141,9 @@ Every time a package/theme is installed or removed, the `bundle` file is updated
Oh My Fish uses an advanced and well defined plugin architecture to ease plugin development, including init/uninstall hooks, function and completion autoloading. [See the packages documentation](docs/en-US/Packages.md) for more details.
[fishshell]: http://fishshell.com
[fishshell]: http://fishshell.com
[contributors]: https://github.com/oh-my-fish/oh-my-fish/graphs/contributors
[omf-pulls-link]: https://github.com/oh-my-fish/oh-my-fish/pulls
[omf-issues-new]: https://github.com/oh-my-fish/oh-my-fish/issues/new
[releases]: https://github.com/oh-my-fish/oh-my-fish/releases
This diff is collapsed.
function omf.cli.destroy
echo (omf::err)"This will destroy your Oh My Fish installation!"(omf::off)
read -l decision -p 'echo -n "Are you sure you want to continue? (y/N) "'
switch $decision
case 'y' 'Y'
omf.destroy
case '*'
echo (omf::err)"Aborted!"(omf::off)
end
omf.destroy
end
function __omf.destroy.restore_backup -a file_path
set -l path (dirname $file_path)
set -l file (basename $file_path)
set -l name (echo $file | cut -d. -f1)
set -l backup_file_list $path/$name.*.copy
set -l backup_file_path (echo $backup_file_list | tr ' ' '\n' | sort -r | head -1)
if test -e "$backup_file_path"
mv "$backup_file_path" "$path/$file" ^/dev/null
else
rm -f "$path/$file" ^/dev/null
end
end
function omf.destroy -d "Remove Oh My Fish"
echo (omf::dim)"Removing Oh My Fish..."(omf::off)
set -l installed_package_path $OMF_PATH/pkg/*
for pkg in (basename -a $installed_package_path)
emit uninstall_$pkg
end
set -q XDG_CONFIG_HOME;
or set -l XDG_CONFIG_HOME "$HOME/.config"
set -l fish_config_home $XDG_CONFIG_HOME/fish
set -l fish_prompt_home $fish_config_home/functions
__omf.destroy.restore_backup "$fish_config_home/config.fish"
__omf.destroy.restore_backup "$fish_prompt_home/fish_prompt.fish"
if test "$OMF_PATH" != "$HOME"
rm -rf "$OMF_PATH"
end
# Run the uninstaller
fish "$OMF_PATH/bin/install" --uninstall "--path=$OMF_PATH" "--config=$OMF_CONFIG"
# Start a new OMF-free shell
set -q CI; or exec fish < /dev/tty
end
#!/usr/bin/env bash
if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update
sudo apt-get install --only-upgrade -y git
else
brew update
brew install git
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment