Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
O
oh-my-fish
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
oh-my-fish
Commits
3aad3800
Commit
3aad3800
authored
Oct 14, 2015
by
Bruno
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #121 from derekstavis/merge-theme-and-install
Overhaul install and update code
parents
2f3a8cdf
2ac04c7e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
48 deletions
+80
-48
pkg/omf/cli/omf.install.fish
pkg/omf/cli/omf.install.fish
+29
-36
pkg/omf/cli/omf.install_package.fish
pkg/omf/cli/omf.install_package.fish
+1
-1
pkg/omf/cli/omf.packages.list.fish
pkg/omf/cli/omf.packages.list.fish
+6
-2
pkg/omf/cli/omf.theme.fish
pkg/omf/cli/omf.theme.fish
+7
-1
pkg/omf/cli/omf.update.fish
pkg/omf/cli/omf.update.fish
+25
-0
pkg/omf/omf.fish
pkg/omf/omf.fish
+12
-8
No files found.
pkg/omf/cli/omf.install.fish
View file @
3aad3800
function omf.install -a
type_flag
name_or_url
function _
display_
success
function omf.install -a name_or_url
function _
_omf.install.
success
echo (omf::em)"✔ $argv successfully installed."(omf::off)
end
function _
display_
error
function _
_omf.install.
error
echo (omf::err)"Could not install $argv."(omf::off) 1^&2
end
switch $type_flag
case "--theme"
set install_type "theme"
set parent_path "themes"
case "--pkg"
set install_type "package"
set parent_path "pkg"
case "*"
echo (omf::err)"Argument to omf.install must be --theme [name|URL] or --pkg [name|URL]"(omf::off)
return $OMF_INVALID_ARG
if test \( -e $OMF_PATH/db/themes/$name_or_url \) -o (echo $name_or_url | grep theme-)
set install_type "theme"
set parent_path "themes"
else
set install_type "package"
set parent_path "pkg"
end
if test -e $OMF_PATH/db/$parent_path/$name_or_url
set target $parent_path/$name_or_url
set name $name_or_url
set url (cat $OMF_PATH/db/$parent_path/$name_or_url)
else
set -l local_name (basename $name_or_url | sed "s/^pkg-//;s/^plugin-//;s/^theme-//")
if test -e $OMF_PATH/$parent_path/$local_name
echo (omf::err)"Error: $local_name $install_type already installed."(omf::off) 1^&2
else
echo (omf::dim)"Trying to clone from URL..."(omf::off)
if omf.repo.clone $name_or_url $OMF_PATH/$parent_path/$local_name
omf.bundle.add $install_type $name_or_url
_display_success "$install_type $name_or_url"
else
_display_error "$install_type $name_or_url"
return $OMF_UNKNOWN_ERR
end
end
return 0
set name (basename $name_or_url | sed 's/^pkg-//;s/^plugin-//;s/^theme-//;s/\.git$//')
set url $name_or_url
end
if test -e $OMF_PATH/$target
echo (omf::dim)"Updating $name_or_url $install_type..."(omf::off)
omf.repo.pull $OMF_PATH/$target
echo (omf::em)"✔ $name_or_url $install_type up to date."(omf::off)
if test -e $OMF_PATH/$parent_path/$name
if test "$install_type" = theme
omf.theme $name
else
echo (omf::err)"Error: $name $install_type already installed."(omf::off) 1^&2
return $OMF_INVALID_ARG
end
else
echo (omf::dim)"Installing $name_or_url $install_type..."(omf::off)
if omf.repo.clone (cat $OMF_PATH/db/$target) $OMF_PATH/$target
echo (omf::dim)"Installing $install_type $name"(omf::off)
if omf.repo.clone $url $OMF_PATH/$parent_path/$name
omf.bundle.add $install_type $name_or_url
_display_success "$install_type $name_or_url"
__omf.install.success "$install_type $name"
if test "$install_type" = theme
omf.theme $name
end
else
_
display_error "$install_type $name_or_url
"
_
_omf.install.error "$install_type $name
"
return $OMF_UNKNOWN_ERR
end
end
...
...
pkg/omf/cli/omf.install_package.fish
View file @
3aad3800
function omf.install_package
for search in $argv
omf.install
--pkg
$search
omf.install $search
end
end
pkg/omf/cli/omf.packages.list.fish
View file @
3aad3800
...
...
@@ -2,11 +2,15 @@ function __omf.packages.sort
for package in (echo $argv | tr ' ' '\n' | sort); echo $package; end
end
function __omf.packages.builtin
echo "omf"
end
function __omf.packages.list -a type
set -l list
test "$type" = "--theme"; or for package in (basename {$OMF_CONFIG,$OMF_PATH/db}/pkg/*)
set list $list $package
contains $package (__omf.packages.builtin); or
set list $list $package
end
test "$type" = "--plugin"; or for package in (basename {$OMF_CONFIG,$OMF_PATH/db}/themes/*)
...
...
@@ -48,7 +52,7 @@ function __omf.packages.list.installed -a type
set -l list
test "$type" = "--theme"; or for package in (basename {$OMF_CONFIG,$OMF_PATH}/pkg/*)
set list $list $package
contains $package (__omf.packages.builtin); or
set list $list $package
end
test "$type" = "--plugin"; or for package in (basename {$OMF_CONFIG,$OMF_PATH}/themes/*)
...
...
pkg/omf/cli/omf.theme.fish
View file @
3aad3800
function omf.theme -a target_theme
if not contains "$target_theme" (omf.packages.list --installed --theme)
echo (omf::err)"Theme not installed!"(omf::off)
echo Install it using (omf::em)omf install $target_theme(omf::off)
return $OMF_INVALID_ARG
end
set -l current_theme (cat $OMF_CONFIG/theme)
test "$target_theme" = "$current_theme"; and return 0
...
...
@@ -10,7 +16,7 @@ function omf.theme -a target_theme
if not omf.check.fish_prompt
echo (omf::err)"Conflicting prompt setting."(omf::off)
echo "Run "(omf::em)"omf doctor"(omf::off)" and fix issues before continuing."
return
1
return
$OMF_INVALID_ARG
end
# Replace autoload paths of current theme with the target one
...
...
pkg/omf/cli/omf.update.fish
0 → 100644
View file @
3aad3800
function omf.update -a name
function __omf.update.success
echo (omf::em)"✔ $argv successfully updated."(omf::off)
end
function __omf.update.error
echo (omf::err)"Could not update $argv."(omf::off) 1^&2
end
if test \( -e $OMF_PATH/themes/$name \) -o \( -e $OMF_CONFIG/themes/$name \)
set install_type "theme"
set parent_path "themes"
else
set install_type "package"
set parent_path "pkg"
end
for path in {$OMF_PATH,$OMF_CONFIG}/pkg/$name
not test -e "$path/.git"; and continue
omf.repo.pull $path; and set return_success
end
set -q return_success; and __omf.update.success "$name"
end
pkg/omf/omf.fish
View file @
3aad3800
...
...
@@ -78,8 +78,13 @@ function omf -d "Oh My Fish"
if test (count $argv) -eq 1
omf.bundle.install
else
omf.install_package $argv[2..-1]
refresh
for package in $argv[2..-1]
if omf.install $package
set refresh
end
end
set -q refresh; and refresh
end
case "l" "ls" "list"
...
...
@@ -121,9 +126,6 @@ function omf -d "Oh My Fish"
omf.packages.list --database --theme | column | sed -E "s/$regex/"(omf::em)"\1"(omf::off)"/"
omf::off
else if test (count $argv) -eq 2
if not contains -- $argv[2] (omf.packages.list --installed)
omf.install --theme $argv[2]; or return 1
end
omf.theme $argv[2]
else
echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2
...
...
@@ -139,10 +141,12 @@ function omf -d "Oh My Fish"
echo (omf::err)"Oh My Fish failed to update."(omf::off)
echo "Please open a new issue here → "(omf::em)"github.com/oh-my-fish/oh-my-fish/issues"(omf::off)
end
omf.theme (cat $OMF_CONFIG/theme)
omf.install_package (omf.packages.list --installed --plugin)
refresh
for package in (omf.packages.list --installed)
omf.update $package
end
refresh
case "*"
echo (omf::err)"$argv[1] option not recognized"(omf::off) 1^&2
return $OMF_UNKNOWN_OPT
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment