Commit c232f101 authored by Bruno Pinto's avatar Bruno Pinto

Closes #381: oh-my-fish self update

parent 64974603
...@@ -13,6 +13,12 @@ function omf -d "Oh My Fish helper" ...@@ -13,6 +13,12 @@ function omf -d "Oh My Fish helper"
omf.packages --update omf.packages --update
case 'list' 'ls' case 'list' 'ls'
omf.packages --list omf.packages --list
case 'self-update'
omf.git --update $fish_path
if [ $status -eq 0 ]
omf.log 'green' 'Oh My Fish has been successfully updated.'
end
case '*' case '*'
omf.helper omf.helper
end end
......
function omf.git
switch $argv[1]
case '--clone'
set -l repo_url $argv[2]
set -l path $argv[3]
git clone --quiet $repo_url $path ^ /tmp/oh-my-fish.clone.log
case '--update'
set -l path $argv[2]
return (cd $path; and git pull --rebase > /dev/null; echo $status)
case '*'
omf.log red 'Unknown option'
end
end
...@@ -12,5 +12,6 @@ function omf.helper -d 'Prints all functions supported by Oh My Fish helper' ...@@ -12,5 +12,6 @@ function omf.helper -d 'Prints all functions supported by Oh My Fish helper'
omf.log normal ' omf install' omf.log normal ' omf install'
omf.log normal ' omf update' omf.log normal ' omf update'
omf.log normal ' omf list' omf.log normal ' omf list'
omf.log normal ' omf self-update'
end end
...@@ -65,6 +65,7 @@ function omf.packages.report.failed -e omf_package_install_failed -e omf_package ...@@ -65,6 +65,7 @@ function omf.packages.report.failed -e omf_package_install_failed -e omf_package
set_color yellow set_color yellow
cat /tmp/oh-my-fish.clone.log cat /tmp/oh-my-fish.clone.log
echo -e ''
set_color normal set_color normal
set __omf_packages_modified (expr $__omf_packages_modified + 1) set __omf_packages_modified (expr $__omf_packages_modified + 1)
......
...@@ -15,7 +15,7 @@ function omf.packages.install --argument-names type name -d "Install a plugin or ...@@ -15,7 +15,7 @@ function omf.packages.install --argument-names type name -d "Install a plugin or
# Plugin is already installed. Skipping. # Plugin is already installed. Skipping.
else else
emit omf_package_installing $name emit omf_package_installing $name
git clone --quiet "https://github.com/oh-my-fish/plugin-$name" $fish_path/plugins/$name ^ /tmp/oh-my-fish.clone.log omf.git --clone "https://github.com/oh-my-fish/plugin-$name" $fish_path/plugins/$name
if [ $status -eq 0 ] if [ $status -eq 0 ]
emit omf_package_installed $name emit omf_package_installed $name
...@@ -28,7 +28,7 @@ function omf.packages.install --argument-names type name -d "Install a plugin or ...@@ -28,7 +28,7 @@ function omf.packages.install --argument-names type name -d "Install a plugin or
# Theme is already installed. Skipping. # Theme is already installed. Skipping.
else else
emit omf_package_installing $name emit omf_package_installing $name
git clone --quiet "https://github.com/oh-my-fish/theme-$name" $fish_path/themes/$name ^ /tmp/oh-my-fish.clone.log omf.git --clone "https://github.com/oh-my-fish/plugin-$name" $fish_path/themes/$name
if [ $status -eq 0 ] if [ $status -eq 0 ]
emit omf_package_installed $name emit omf_package_installed $name
......
...@@ -15,12 +15,12 @@ function omf.packages.update --argument-names type name -d "Update a plugin or t ...@@ -15,12 +15,12 @@ function omf.packages.update --argument-names type name -d "Update a plugin or t
case '--plugin' case '--plugin'
if [ -e $fish_path/plugins/$name -a -e $fish_path/plugins/$name/.git ] if [ -e $fish_path/plugins/$name -a -e $fish_path/plugins/$name/.git ]
emit omf_package_updating $name emit omf_package_updating $name
echo (cd $fish_path/plugins/$name; and git pull --rebase > /dev/null) >/dev/null omf.git --update $fish_path/plugins/$name
emit omf_package_updated $name emit omf_package_updated $name
else else
if [ -e $fish_custom/plugins/$name -a -e $fish_custom/plugins/$name/.git ] if [ -e $fish_custom/plugins/$name -a -e $fish_custom/plugins/$name/.git ]
emit omf_package_updating $name emit omf_package_updating $name
echo (cd $fish_custom/plugins/$name; and git pull --rebase > /dev/null) >/dev/null omf.git --update $fish_path/plugins/$name
emit omf_package_updated $name emit omf_package_updated $name
else else
# Plugin is not installed or not a git repo. Skipping. # Plugin is not installed or not a git repo. Skipping.
...@@ -29,12 +29,12 @@ function omf.packages.update --argument-names type name -d "Update a plugin or t ...@@ -29,12 +29,12 @@ function omf.packages.update --argument-names type name -d "Update a plugin or t
case '--theme' case '--theme'
if [ -e $fish_path/themes/$name -a -e $fish_path/themes/$name/.git ] if [ -e $fish_path/themes/$name -a -e $fish_path/themes/$name/.git ]
emit omf_package_updating $name emit omf_package_updating $name
echo (cd $fish_path/themes/$name; and git pull --rebase > /dev/null) >/dev/null omf.git --update $fish_path/themes/$name
emit omf_package_updated $name emit omf_package_updated $name
else else
if [ -e $fish_custom/themes/$name -a -e $fish_custom/themes/$name/.git ] if [ -e $fish_custom/themes/$name -a -e $fish_custom/themes/$name/.git ]
emit omf_package_updating $name emit omf_package_updating $name
echo (cd $fish_custom/themes/$name; and git pull --rebase > /dev/null) >/dev/null omf.git --update $fish_custom/themes/$name
emit omf_package_updated $name emit omf_package_updated $name
else else
# Theme is not installed or not a git repo. Skipping. # Theme is not installed or not a git repo. Skipping.
......
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