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
beca6512
Commit
beca6512
authored
Oct 05, 2015
by
Bruno
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #99 from derekstavis/remove-from-autoload
Implement `autoload -e` option to remove from autoload paths
parents
ee4fc5bb
ebd7192c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
17 deletions
+63
-17
lib/README.md
lib/README.md
+13
-3
lib/autoload.fish
lib/autoload.fish
+50
-14
No files found.
lib/README.md
View file @
beca6512
...
...
@@ -8,15 +8,25 @@
## Basic Functions
#### `autoload` _`<path [path...]>`_
Autoload a function or completion path. Add the specified list of directories to
`$fish_function_path`
.
#### `autoload` _`[-e] <path>...`_
Any
`completions`
directories are correctly added to the
`$fish_complete_path`
.
Manipulate
[
autoloading
](
http://fishshell.com/docs/current/index.html#syntax-function-autoloading
)
path components.
All paths ending with
`completions`
are correctly added to or erased from
`$fish_complete_path`
.
To add paths to autoload:
```
fish
autoload $mypath $mypath/completions
```
To erase paths from autoload:
```
fish
autoload -e $mypath $mypath/completions
```
#### `available` _`<name>`_
Check if a program is available to run. Sets
`$status`
to
`0`
if the program is available.
...
...
lib/autoload.fish
View file @
beca6512
# SYNOPSIS
# autoload <path>...
# autoload -e <path>...
#
# OVERVIEW
# Autoload a function or completion path. Add the specified list of
# directories to $fish_function_path. Any `completions` directories
# are correctly added to the $fish_complete_path.
# Manipulate autoloading path components.
#
# Returns 0 if one of the paths exist.
# Returns != 0 if all paths are missing.
# If called without options, the paths passed as arguments are added to
# $fish_function_path. All paths ending with `completions` are correctly
# added to $fish_complete_path. Returns 0 if one or more paths exist. If all
# paths are missing, returns != 0.
#
# When called with -e, the paths passed as arguments are removed from
# $fish_function_path. All arguments ending with `completions` are correctly
# removed from $fish_complete_path. Returns 0 if one or more paths erased. If
# no paths were erased, returns != 0.
function autoload -d "Manipulate autoloading path components"
set -l paths $argv
switch "$argv[1]"
case '-e' '--erase'
set erase
if test (count $argv) -ge 2
set paths $argv[2..-1]
else
echo "usage: autoload $argv[1] <path>..." 1>&2
return 1
end
case "-*" "--*"
echo "autoload: invalid option $argv[1]"
return 1
end
for path in $paths
not test -d "$path"; and continue
function autoload -d "autoload a function or completion path"
for path in $argv
set -l dest fish_function_path
if test -d "$path"
set path_exist
if test (basename "$path") = completions
set dest fish_complete_path
end
if set -q erase
not contains -- "$path" $$dest; and continue
# Make a copy of function path selected above
set -l function_path $$dest
if test (basename "$path") = completions
set dest fish_complete_path
end
set -l index (contains -i -- $path $function_path)
set -e function_path[$index]
contains "$path" $$dest; or set $dest "$path" $$dest
# Set function path to modified copy
set $dest $function_path
set return_success
else
set return_success
contains -- "$path" $$dest; and continue
set $dest "$path" $$dest
end
end
set -q
path_exist
set -q
return_success
end
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