mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-23 02:59:27 +08:00
Merge pull request #300 from bucaran/improve-install
Improve install.fish
This commit is contained in:
commit
143cc10c42
|
@ -1,68 +1,122 @@
|
||||||
#!/usr/bin/env fish
|
#!/usr/bin/env fish
|
||||||
|
#
|
||||||
|
# Oh-my-fish is a user-friendly framework for managing your fish-shell
|
||||||
|
# configuration. It includes optional plugins (brew, git, rails, python,
|
||||||
|
# node, etc) and themes.
|
||||||
|
#
|
||||||
|
# Get the party started with:
|
||||||
|
#
|
||||||
|
# curl -L https://github.com/bpinto/oh-my-fish/raw/master/tools/install.fish \
|
||||||
|
# | fish
|
||||||
|
#
|
||||||
|
# Oh-My-Fish currently supports
|
||||||
|
#
|
||||||
|
# - Fish 2.0+ [fishshell.com] [github.com/fish-shell/fish-shell]
|
||||||
|
#
|
||||||
|
# The installation process is split up in the following steps:
|
||||||
|
#
|
||||||
|
# 1. Resolve source repository to default or get from environment variable.
|
||||||
|
# This allows installers curl -L ..install.fish | FORK=<fork> fish in
|
||||||
|
# order to test forks of the framework.
|
||||||
|
#
|
||||||
|
# 2. Check for already installed copies of Oh-My-Fish. Do not reinstall.
|
||||||
|
#
|
||||||
|
# 3. Attempt to pull repository via git clone, if git is not available,
|
||||||
|
# curl a HTTP GET request directly from github.
|
||||||
|
#
|
||||||
|
# 4. Backup original configuration file if there is one and copy new
|
||||||
|
# configuration file from templates/.
|
||||||
|
#
|
||||||
|
# 5. Print fish logo.
|
||||||
|
#
|
||||||
|
# 6. Start prompt if the terminal is interactive
|
||||||
|
#/
|
||||||
|
|
||||||
# Takes color as first argument, and text to print as other arguments.
|
set fish_path ~/.oh-my-fish
|
||||||
function colored
|
set config_path ~/.config/fish/
|
||||||
set_color $argv[1]
|
|
||||||
set -e argv[1]
|
# Log a color message.
|
||||||
echo $argv
|
# log <color> <string>...
|
||||||
set_color normal
|
function log
|
||||||
|
echo -e (set_color $argv[1])$argv[2..-1](set_color normal)
|
||||||
end
|
end
|
||||||
|
|
||||||
if test -d ~/.oh-my-fish
|
log white "Installing Oh My Fish..."
|
||||||
colored yellow -n You already have Oh My Fish installed.
|
|
||||||
echo " You'll need to remove ~/.oh-my-fish if you want to install"
|
# Allow installers to specify the source repository.
|
||||||
exit
|
if not set -q FORK
|
||||||
|
set FORK bpinto
|
||||||
end
|
end
|
||||||
|
|
||||||
colored blue Cloning Oh My Fish...
|
# Abort installation if oh-my-fish is already installed.
|
||||||
type git >/dev/null
|
if test -d $fish_path
|
||||||
and git clone https://github.com/bpinto/oh-my-fish.git ~/.oh-my-fish
|
log yellow "You already have Oh My Fish installed."
|
||||||
or begin
|
log white "Remove $fish_path if you want to reinstall it."
|
||||||
echo git not installed
|
exit 1
|
||||||
exit
|
|
||||||
end
|
end
|
||||||
|
|
||||||
colored blue Looking for an existing fish config...
|
# Either git clone or curl GET repository.
|
||||||
if test -f ~/.config/fish/config.fish
|
log blue "Cloning Oh My Fish from remote repository..."
|
||||||
colored yellow -n "Found ~/.config/fish/config.fish."
|
if type git >/dev/null
|
||||||
colored green " Backing up to ~/.config/fish/config.orig"
|
git clone "https://github.com/$FORK/oh-my-fish.git" $fish_path
|
||||||
mv ~/.config/fish/config.{fish,orig}
|
else
|
||||||
|
log yellow "Install git to pull Oh-My-Fish updates"
|
||||||
|
log white "Downloading remote zip from Github..."
|
||||||
|
|
||||||
|
if curl -sLo $fish_path.zip "https://github.com/$FORK/oh-my-fish/archive/master.zip"
|
||||||
|
unzip -q $fish_path.zip
|
||||||
|
mv "oh-my-fish-master" $fish_path
|
||||||
|
and log green "Oh-My-Fish succesfully downloaded and extracted to $fish_path"
|
||||||
|
rm -f $fish_path.zip
|
||||||
|
else
|
||||||
|
log red "Oh-My-Fish could not be downloaded."
|
||||||
|
log white "Report an issue → github.com/bpinto/oh-my-fish/issues"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
colored blue "Using the Oh My Fish template file and adding it to ~/.config/fish/config.fish"
|
# Check any existing config.fish files, backup and add custom template.
|
||||||
cp ~/.oh-my-fish/templates/config.fish ~/.config/fish/config.fish
|
log blue "Looking for an existing fish config..."
|
||||||
|
if test -f $config_path/config.fish
|
||||||
colored green \
|
log green "Found $config_path/config.fish."
|
||||||
' _
|
log green "Backing up to $config_path/config.orig"
|
||||||
| |
|
mv $config_path/config.{fish,orig}
|
||||||
___ | |__ _ __ ___ _ _
|
end
|
||||||
/ _ \| _ \ | _ ` _ \| | | |
|
log blue "Adding default configuration file to $config_path/config.fish"
|
||||||
| (_) | | | | | | | | | | |_| |
|
cp $fish_path/templates/config.fish $config_path/config.fish
|
||||||
\___/|_| |_| |_| |_| |_|\__, |
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
'
|
|
||||||
|
|
||||||
# Print nice fish logo with colors.
|
# Print nice fish logo with colors.
|
||||||
echo ' '(set_color F00)'___
|
log green \
|
||||||
___======____='(set_color FF7F00)'-'(set_color FF0)'-'(set_color FF7F00)'-='(set_color F00)')
|
" _
|
||||||
/T \_'(set_color FF0)'--='(set_color FF7F00)'=='(set_color F00)')
|
| |
|
||||||
[ \ '(set_color FF7F00)'('(set_color FF0)'0'(set_color FF7F00)') '(set_color F00)'\~ \_'(set_color FF0)'-='(set_color FF7F00)'='(set_color F00)')
|
___ | |__ _ __ ___ _ _
|
||||||
\ / )J'(set_color FF7F00)'~~ \\'(set_color FF0)'-='(set_color F00)')
|
/ _ \| _ \ | _ ` _ \| | | |
|
||||||
\\\\___/ )JJ'(set_color FF7F00)'~'(set_color FF0)'~~ '(set_color F00)'\)
|
| (_) | | | | | | | | | | |_| |
|
||||||
\_____/JJJ'(set_color FF7F00)'~~'(set_color FF0)'~~ '(set_color F00)'\\
|
\___/|_| |_| |_| |_| |_|\__, |
|
||||||
'(set_color FF7F00)'/ '(set_color FF0)'\ '(set_color FF0)', \\'(set_color F00)'J'(set_color FF7F00)'~~~'(set_color FF0)'~~ '(set_color FF7F00)'\\
|
__/ |
|
||||||
(-'(set_color FF0)'\)'(set_color F00)'\='(set_color FF7F00)'|'(set_color FF0)'\\\\\\'(set_color FF7F00)'~~'(set_color FF0)'~~ '(set_color FF7F00)'L_'(set_color FF0)'_
|
|___/
|
||||||
'(set_color FF7F00)'('(set_color F00)'\\'(set_color FF7F00)'\\) ('(set_color FF0)'\\'(set_color FF7F00)'\\\)'(set_color F00)'_ '(set_color FF0)'\=='(set_color FF7F00)'__
|
"
|
||||||
'(set_color F00)'\V '(set_color FF7F00)'\\\\'(set_color F00)'\) =='(set_color FF7F00)'=_____ '(set_color FF0)'\\\\\\\\'(set_color FF7F00)'\\\\
|
|
||||||
'(set_color F00)'\V) \_) '(set_color FF7F00)'\\\\'(set_color FF0)'\\\\JJ\\'(set_color FF7F00)'J\)
|
|
||||||
'(set_color F00)'/'(set_color FF7F00)'J'(set_color FF0)'\\'(set_color FF7F00)'J'(set_color F00)'T\\'(set_color FF7F00)'JJJ'(set_color F00)'J)
|
|
||||||
(J'(set_color FF7F00)'JJ'(set_color F00)'| \UUU)
|
|
||||||
(UU)'(set_color normal)
|
|
||||||
|
|
||||||
echo
|
echo " "(set_color F00)"___
|
||||||
echo
|
___======____="(set_color FF7F00)"-"(set_color FF0)"-"(set_color FF7F00)"-="(set_color F00)")
|
||||||
colored green ' ....is now installed.'
|
/T \_"(set_color FF0)"--="(set_color FF7F00)"=="(set_color F00)")
|
||||||
|
[ \ "(set_color FF7F00)"("(set_color FF0)"0"(set_color FF7F00)") "(set_color F00)"\~ \_"(set_color FF0)"-="(set_color FF7F00)"="(set_color F00)")
|
||||||
|
\ / )J"(set_color FF7F00)"~~ \\"(set_color FF0)"-="(set_color F00)")
|
||||||
|
\\\\___/ )JJ"(set_color FF7F00)"~"(set_color FF0)"~~ "(set_color F00)"\)
|
||||||
|
\_____/JJJ"(set_color FF7F00)"~~"(set_color FF0)"~~ "(set_color F00)"\\
|
||||||
|
"(set_color FF7F00)"/ "(set_color FF0)"\ "(set_color FF0)", \\"(set_color F00)"J"(set_color FF7F00)"~~~"(set_color FF0)"~~ "(set_color FF7F00)"\\
|
||||||
|
(-"(set_color FF0)"\)"(set_color F00)"\="(set_color FF7F00)"|"(set_color FF0)"\\\\\\"(set_color FF7F00)"~~"(set_color FF0)"~~ "(set_color FF7F00)"L_"(set_color FF0)"_
|
||||||
|
"(set_color FF7F00)"("(set_color F00)"\\"(set_color FF7F00)"\\) ("(set_color FF0)"\\"(set_color FF7F00)"\\\)"(set_color F00)"_ "(set_color FF0)"\=="(set_color FF7F00)"__
|
||||||
|
"(set_color F00)"\V "(set_color FF7F00)"\\\\"(set_color F00)"\) =="(set_color FF7F00)"=_____ "(set_color FF0)"\\\\\\\\"(set_color FF7F00)"\\\\
|
||||||
|
"(set_color F00)"\V) \_) "(set_color FF7F00)"\\\\"(set_color FF0)"\\\\JJ\\"(set_color FF7F00)"J\)
|
||||||
|
"(set_color F00)"/"(set_color FF7F00)"J"(set_color FF0)"\\"(set_color FF7F00)"J"(set_color F00)"T\\"(set_color FF7F00)"JJJ"(set_color F00)"J)
|
||||||
|
(J"(set_color FF7F00)"JJ"(set_color F00)"| \UUU)\\
|
||||||
|
(UU)"(set_color normal)\n\n
|
||||||
|
|
||||||
# Run shell after installation.
|
log green "...is now installed."
|
||||||
exec fish < /dev/tty
|
|
||||||
|
# Launch fish after installation, loading Oh My Fish for the first time.
|
||||||
|
# Safeguard for non-interactive terminals, automated installers, etc.
|
||||||
|
if status --is-interactive
|
||||||
|
exec fish < /dev/tty
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user