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
a1243f65
Commit
a1243f65
authored
Oct 02, 2015
by
Bruno
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #83 from oh-my-fish/faster-loading
Faster loading
parents
2040eedc
e2a7f7d2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
15 deletions
+51
-15
init.fish
init.fish
+10
-6
lib/autoload.fish
lib/autoload.fish
+9
-2
lib/available.fish
lib/available.fish
+3
-3
lib/require.fish
lib/require.fish
+26
-0
pkg/omf/init.fish
pkg/omf/init.fish
+3
-0
pkg/omf/omf.fish
pkg/omf/omf.fish
+0
-4
No files found.
init.fish
View file @
a1243f65
...
@@ -41,16 +41,20 @@ source $OMF_CONFIG/before.init.fish ^/dev/null
...
@@ -41,16 +41,20 @@ source $OMF_CONFIG/before.init.fish ^/dev/null
set -l user_function_path $fish_function_path[1]
set -l user_function_path $fish_function_path[1]
set fish_function_path[1] $OMF_PATH/lib
set fish_function_path[1] $OMF_PATH/lib
set -l theme {$OMF_PATH,$OMF_CONFIG}/themes/(cat $OMF_CONFIG/theme)
# Autoload util functions
autoload $OMF_PATH/lib $OMF_PATH/lib/git
for path in
$OMF_PATH/lib $OMF_PATH/lib/git {$OMF_PATH,$OMF_CONFIG}/pkg/* $theme
for path in
{$OMF_PATH,$OMF_CONFIG}/pkg/*
contains -- (basename $path) $OMF_IGNORE; and continue
set -l name (basename $path)
autoload $path $path/completions
contains -- $name $OMF_IGNORE; and continue
source $path/(basename $path).fish ^/dev/null
require $name
and emit init_(basename $path) $path
end
end
# Autoload theme
autoload {$OMF_PATH,$OMF_CONFIG}/themes/(cat $OMF_CONFIG/theme)
# Autoload custom functions
autoload $OMF_CONFIG/functions
autoload $OMF_CONFIG/functions
autoload $user_function_path
autoload $user_function_path
...
...
lib/autoload.fish
View file @
a1243f65
# SYNOPSIS
# SYNOPSIS
# autoload <path
[path...]>
# autoload <path
>...
#
#
# OVERVIEW
# OVERVIEW
# Autoload a function or completion path. Add the specified list of
# Autoload a function or completion path. Add the specified list of
# directories to $fish_function_path. Any `completions` directories
# directories to $fish_function_path. Any `completions` directories
# are correctly added to the $fish_complete_path.
# are correctly added to the $fish_complete_path.
#
# Returns 0 if one of the paths exist.
# Returns != 0 if all paths are missing.
function autoload -d "autoload a function or completion path"
function autoload -d "autoload a function or completion path"
for path in $argv
for path in $argv
set -l dest fish_function_path
if test -d "$path"
if test -d "$path"
set
-l dest fish_function_path
set
path_exist
if test (basename "$path") = completions
if test (basename "$path") = completions
set dest fish_complete_path
set dest fish_complete_path
...
@@ -18,4 +23,6 @@ function autoload -d "autoload a function or completion path"
...
@@ -18,4 +23,6 @@ function autoload -d "autoload a function or completion path"
contains "$path" $$dest; or set $dest "$path" $$dest
contains "$path" $$dest; or set $dest "$path" $$dest
end
end
end
end
set -q path_exist
end
end
lib/available.fish
View file @
a1243f65
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
# available [name]
# available [name]
#
#
# OVERVIEW
# OVERVIEW
# Check if a program is available.
# Check if a
function or
program is available.
function available -a
program -d "check if a
program is available."
function available -a
name -d "Check if a function or
program is available."
type "$
program
" ^/dev/null >&2
type "$
name
" ^/dev/null >&2
end
end
lib/require.fish
0 → 100644
View file @
a1243f65
# SYNOPSIS
# require [name]
#
# OVERVIEW
# Require a plugin:
# - Autoload its functions and completions.
# - Source its initialization file.
# - Emit its initialization event.
#
# If the required plugin has already been loaded, does nothing.
function require -a name
# Skip if plugin has already been loaded.
contains -- $OMF_PATH/pkg/$name $fish_function_path;
or contains -- $OMF_CONFIG/pkg/$name $fish_function_path;
and return 0
for path in {$OMF_PATH,$OMF_CONFIG}/pkg/$name
if autoload $path $path/completions
source $path/init.fish ^/dev/null;
or source $path/$name.fish ^/dev/null;
and emit init_$name $path
end
end
end
pkg/omf/init.fish
0 → 100644
View file @
a1243f65
function init -a path --on-event init_omf
autoload $path/cli $path/util
end
pkg/omf/omf.fish
View file @
a1243f65
...
@@ -29,10 +29,6 @@ function omf::off
...
@@ -29,10 +29,6 @@ function omf::off
set_color normal
set_color normal
end
end
function init -a path --on-event init_omf
autoload $path/cli $path/util
end
function omf -d "Oh My Fish"
function omf -d "Oh My Fish"
if test (count $argv) -eq 0
if test (count $argv) -eq 0
omf.help "main"; and return 0
omf.help "main"; and return 0
...
...
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