From 2693a2fd18bd92a439f4d74b10513922d92120f7 Mon Sep 17 00:00:00 2001 From: Jorge Bucaran Date: Thu, 27 Aug 2015 00:20:13 +0900 Subject: [PATCH] =?UTF-8?q?%%%=20United=20States=20of=20the=20Fish=20?= =?UTF-8?q?=E2=86=92=20Wahoo=20+=20OMF=20%%%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 10 +- .gitignore | 18 +- .travis.yml | 31 +-- CONTRIBUTING.md | 138 ++++++++-- Dockerfile | 18 -- FAQ.md | 89 +++++++ LICENSE | 2 +- README.md | 247 +++++++++++++++--- bin/install | 120 +++++++++ custom/example.load | 5 - .../plugins/example/completions/example.fish | 2 - custom/plugins/example/example.fish | 2 - db/pkg/ansible | 1 + db/pkg/battery | 1 + db/pkg/copy | 1 + db/pkg/direnv | 1 + db/pkg/emacs | 1 + db/pkg/extract | 1 + db/pkg/fasd | 1 + db/pkg/gi | 1 + db/pkg/hub | 1 + db/pkg/keychain | 1 + db/pkg/limap | 1 + db/pkg/osx_manpath | 1 + db/pkg/peco | 1 + db/pkg/pyenv | 1 + db/pkg/rbenv | 1 + db/pkg/set_color | 1 + db/pkg/stamp | 1 + db/pkg/thefuck | 1 + db/pkg/tiny | 1 + db/themes/agnoster | 1 + db/themes/agnoster copy | 1 + db/themes/agnoster-mercurial | 1 + db/themes/batman | 1 + db/themes/beloglazov | 1 + db/themes/bira | 1 + db/themes/bobthefish | 1 + db/themes/budspencer | 1 + db/themes/cbjohnson | 1 + db/themes/clearance | 1 + db/themes/cmorrell | 1 + db/themes/coffeeandcode | 1 + db/themes/cor | 1 + db/themes/dangerous | 1 + db/themes/eclm | 1 + db/themes/edan | 1 + db/themes/fishface | 1 + db/themes/fishy-drupal | 1 + db/themes/fisk | 1 + db/themes/flash | 1 + db/themes/fox | 1 + db/themes/gianu | 1 + db/themes/gitstatus | 1 + db/themes/gnuykeaj | 1 + db/themes/godfather | 1 + db/themes/hogan | 1 + db/themes/hulk | 1 + db/themes/idan | 1 + db/themes/integral | 1 + db/themes/jacaetevha | 1 + db/themes/krisleech | 1 + db/themes/l | 1 + db/themes/led | 1 + db/themes/mtahmed | 1 + db/themes/nai | 1 + db/themes/numist | 1 + db/themes/ocean | 1 + db/themes/perryh | 1 + db/themes/red-snapper | 1 + db/themes/robbyrussell | 1 + db/themes/russell | 1 + db/themes/scorphish | 1 + db/themes/simplevi | 1 + db/themes/syl20bnr | 1 + db/themes/taktoa | 1 + db/themes/technopagan | 1 + db/themes/toaster | 1 + db/themes/tomita | 1 + db/themes/trout | 1 + db/themes/uggedal | 1 + db/themes/will | 1 + db/themes/yimmy | 1 + db/themes/zish | 1 + functions/Plugin.fish | 11 - functions/Theme.fish | 11 - functions/_prepend_path.fish | 48 ---- functions/_prepend_tree.fish | 105 -------- functions/import.fish | 53 ---- functions/restore_original_fish_colors.fish | 29 -- functions/source_script.fish | 94 ------- init.fish | 54 ++++ lib/README.md | 78 ++++++ lib/autoload.fish | 19 ++ lib/available.fish | 9 + lib/basename.fish | 29 ++ .../.gitignore => lib/completions/.gitkeep | 0 lib/git/git_ahead.fish | 15 ++ lib/git/git_branch_name.fish | 5 + lib/git/git_is_dirty.fish | 3 + lib/git/git_is_repo.fish | 3 + lib/git/git_is_staged.fish | 5 + lib/git/git_is_stashed.fish | 5 + lib/git/git_is_touched.fish | 5 + lib/git/git_untracked.fish | 5 + lib/prompt_segments.fish | 24 ++ lib/refresh.fish | 9 + oh-my-fish.fish | 50 ---- pkg/omf/cli/omf_destroy.fish | 19 ++ pkg/omf/cli/omf_help.fish | 20 ++ pkg/omf/cli/omf_list_db_packages.fish | 6 + pkg/omf/cli/omf_list_installed_packages.fish | 6 + pkg/omf/cli/omf_list_installed_themes.fish | 5 + pkg/omf/cli/omf_list_local_packages.fish | 6 + pkg/omf/cli/omf_list_themes.fish | 8 + pkg/omf/cli/omf_new.fish | 34 +++ pkg/omf/cli/omf_new_from_template.fish | 27 ++ pkg/omf/cli/omf_package.fish | 34 +++ pkg/omf/cli/omf_query_env.fish | 17 ++ pkg/omf/cli/omf_remove_package.fish | 32 +++ pkg/omf/cli/omf_submit.fish | 42 +++ pkg/omf/cli/omf_update.fish | 16 ++ pkg/omf/cli/omf_use.fish | 18 ++ pkg/omf/cli/omf_version.fish | 3 + pkg/omf/completions/omf.fish | 30 +++ pkg/omf/omf.fish | 126 +++++++++ pkg/omf/templates/pkg/.travis.yml | 16 ++ pkg/omf/templates/pkg/LICENSE | 21 ++ pkg/omf/templates/pkg/README.md | 40 +++ .../templates/pkg/completions/{{NAME}}.fish | 1 + pkg/omf/templates/pkg/test/{{NAME}}.fish | 1 + pkg/omf/templates/pkg/{{NAME}}.fish | 18 ++ pkg/omf/templates/themes/LICENSE | 21 ++ pkg/omf/templates/themes/README.md | 40 +++ pkg/omf/templates/themes/fish_greeting.fish | 12 + pkg/omf/templates/themes/fish_prompt.fish | 4 + .../templates/themes/fish_right_prompt.fish | 3 + pkg/omf/templates/themes/fish_title.fish | 3 + pkg/omf/util/omf_util_fork_repo.fish | 4 + pkg/omf/util/omf_util_mkdir.fish | 10 + pkg/omf/util/omf_util_sync.fish | 8 + pkg/omf/util/omf_util_valid_package.fish | 14 + plugins/README.md | 49 ---- plugins/fish-spec/README.md | 109 -------- plugins/fish-spec/eval.fish | 60 ----- plugins/fish-spec/expect.fish | 94 ------- plugins/fish-spec/list.erase.fish | 41 --- plugins/fish-spec/spec.eval.fish | 34 --- plugins/fish-spec/spec.functions.fish | 106 -------- plugins/fish-spec/spec.run.fish | 93 ------- plugins/fish-spec/spec.view.fish | 118 --------- plugins/fish-spec/spec/expect.spec.fish | 14 - .../spec/expect.to_be_false.spec.fish | 29 -- .../spec/expect.to_be_true.spec.fish | 29 -- .../spec/expect.to_contain_all.spec.fish | 53 ---- .../fish-spec/spec/expect.to_equal.spec.fish | 29 -- .../spec/expect.to_not_contain_all.spec.fish | 53 ---- plugins/fish-spec/spec/list.erase.spec.fish | 71 ----- plugins/fish-spec/spec/spec.spec.fish | 155 ----------- plugins/omf/omf.fish | 32 --- plugins/omf/omf.git.fish | 16 -- plugins/omf/omf.helper.fish | 18 -- plugins/omf/omf.log.fish | 17 -- plugins/omf/omf.packages.fish | 98 ------- plugins/omf/omf.packages.install.fish | 42 --- plugins/omf/omf.packages.update.fish | 48 ---- plugins/omf/omf.remote.fish | 39 --- script/bootstrap.sh | 12 - script/run-tests.fish | 8 - spec/import.spec.fish | 47 ---- spec/oh-my-fish.spec.fish | 71 ----- templates/config.fish | 13 - themes/.gitignore | 0 tools/install.fish | 123 --------- 174 files changed, 1566 insertions(+), 2243 deletions(-) delete mode 100644 Dockerfile create mode 100644 FAQ.md create mode 100755 bin/install delete mode 100644 custom/example.load delete mode 100644 custom/plugins/example/completions/example.fish delete mode 100644 custom/plugins/example/example.fish create mode 100644 db/pkg/ansible create mode 100644 db/pkg/battery create mode 100644 db/pkg/copy create mode 100644 db/pkg/direnv create mode 100644 db/pkg/emacs create mode 100644 db/pkg/extract create mode 100644 db/pkg/fasd create mode 100644 db/pkg/gi create mode 100644 db/pkg/hub create mode 100644 db/pkg/keychain create mode 100644 db/pkg/limap create mode 100644 db/pkg/osx_manpath create mode 100644 db/pkg/peco create mode 100644 db/pkg/pyenv create mode 100644 db/pkg/rbenv create mode 100644 db/pkg/set_color create mode 100644 db/pkg/stamp create mode 100644 db/pkg/thefuck create mode 100644 db/pkg/tiny create mode 100644 db/themes/agnoster create mode 100644 db/themes/agnoster copy create mode 100644 db/themes/agnoster-mercurial create mode 100644 db/themes/batman create mode 100644 db/themes/beloglazov create mode 100644 db/themes/bira create mode 100644 db/themes/bobthefish create mode 100644 db/themes/budspencer create mode 100644 db/themes/cbjohnson create mode 100644 db/themes/clearance create mode 100644 db/themes/cmorrell create mode 100644 db/themes/coffeeandcode create mode 100644 db/themes/cor create mode 100644 db/themes/dangerous create mode 100644 db/themes/eclm create mode 100644 db/themes/edan create mode 100644 db/themes/fishface create mode 100644 db/themes/fishy-drupal create mode 100644 db/themes/fisk create mode 100644 db/themes/flash create mode 100644 db/themes/fox create mode 100644 db/themes/gianu create mode 100644 db/themes/gitstatus create mode 100644 db/themes/gnuykeaj create mode 100644 db/themes/godfather create mode 100644 db/themes/hogan create mode 100644 db/themes/hulk create mode 100644 db/themes/idan create mode 100644 db/themes/integral create mode 100644 db/themes/jacaetevha create mode 100644 db/themes/krisleech create mode 100644 db/themes/l create mode 100644 db/themes/led create mode 100644 db/themes/mtahmed create mode 100644 db/themes/nai create mode 100644 db/themes/numist create mode 100644 db/themes/ocean create mode 100644 db/themes/perryh create mode 100644 db/themes/red-snapper create mode 100644 db/themes/robbyrussell create mode 100644 db/themes/russell create mode 100644 db/themes/scorphish create mode 100644 db/themes/simplevi create mode 100644 db/themes/syl20bnr create mode 100644 db/themes/taktoa create mode 100644 db/themes/technopagan create mode 100644 db/themes/toaster create mode 100644 db/themes/tomita create mode 100644 db/themes/trout create mode 100644 db/themes/uggedal create mode 100644 db/themes/will create mode 100644 db/themes/yimmy create mode 100644 db/themes/zish delete mode 100644 functions/Plugin.fish delete mode 100644 functions/Theme.fish delete mode 100644 functions/_prepend_path.fish delete mode 100644 functions/_prepend_tree.fish delete mode 100644 functions/import.fish delete mode 100644 functions/restore_original_fish_colors.fish delete mode 100644 functions/source_script.fish create mode 100644 init.fish create mode 100644 lib/README.md create mode 100644 lib/autoload.fish create mode 100644 lib/available.fish create mode 100644 lib/basename.fish rename plugins/.gitignore => lib/completions/.gitkeep (100%) create mode 100644 lib/git/git_ahead.fish create mode 100644 lib/git/git_branch_name.fish create mode 100644 lib/git/git_is_dirty.fish create mode 100644 lib/git/git_is_repo.fish create mode 100644 lib/git/git_is_staged.fish create mode 100644 lib/git/git_is_stashed.fish create mode 100644 lib/git/git_is_touched.fish create mode 100644 lib/git/git_untracked.fish create mode 100644 lib/prompt_segments.fish create mode 100644 lib/refresh.fish delete mode 100644 oh-my-fish.fish create mode 100644 pkg/omf/cli/omf_destroy.fish create mode 100644 pkg/omf/cli/omf_help.fish create mode 100644 pkg/omf/cli/omf_list_db_packages.fish create mode 100644 pkg/omf/cli/omf_list_installed_packages.fish create mode 100644 pkg/omf/cli/omf_list_installed_themes.fish create mode 100644 pkg/omf/cli/omf_list_local_packages.fish create mode 100644 pkg/omf/cli/omf_list_themes.fish create mode 100644 pkg/omf/cli/omf_new.fish create mode 100644 pkg/omf/cli/omf_new_from_template.fish create mode 100644 pkg/omf/cli/omf_package.fish create mode 100644 pkg/omf/cli/omf_query_env.fish create mode 100644 pkg/omf/cli/omf_remove_package.fish create mode 100644 pkg/omf/cli/omf_submit.fish create mode 100644 pkg/omf/cli/omf_update.fish create mode 100644 pkg/omf/cli/omf_use.fish create mode 100644 pkg/omf/cli/omf_version.fish create mode 100644 pkg/omf/completions/omf.fish create mode 100644 pkg/omf/omf.fish create mode 100644 pkg/omf/templates/pkg/.travis.yml create mode 100644 pkg/omf/templates/pkg/LICENSE create mode 100644 pkg/omf/templates/pkg/README.md create mode 100644 pkg/omf/templates/pkg/completions/{{NAME}}.fish create mode 100644 pkg/omf/templates/pkg/test/{{NAME}}.fish create mode 100644 pkg/omf/templates/pkg/{{NAME}}.fish create mode 100644 pkg/omf/templates/themes/LICENSE create mode 100644 pkg/omf/templates/themes/README.md create mode 100644 pkg/omf/templates/themes/fish_greeting.fish create mode 100644 pkg/omf/templates/themes/fish_prompt.fish create mode 100644 pkg/omf/templates/themes/fish_right_prompt.fish create mode 100644 pkg/omf/templates/themes/fish_title.fish create mode 100644 pkg/omf/util/omf_util_fork_repo.fish create mode 100644 pkg/omf/util/omf_util_mkdir.fish create mode 100644 pkg/omf/util/omf_util_sync.fish create mode 100644 pkg/omf/util/omf_util_valid_package.fish delete mode 100644 plugins/README.md delete mode 100644 plugins/fish-spec/README.md delete mode 100644 plugins/fish-spec/eval.fish delete mode 100644 plugins/fish-spec/expect.fish delete mode 100644 plugins/fish-spec/list.erase.fish delete mode 100644 plugins/fish-spec/spec.eval.fish delete mode 100644 plugins/fish-spec/spec.functions.fish delete mode 100644 plugins/fish-spec/spec.run.fish delete mode 100644 plugins/fish-spec/spec.view.fish delete mode 100644 plugins/fish-spec/spec/expect.spec.fish delete mode 100644 plugins/fish-spec/spec/expect.to_be_false.spec.fish delete mode 100644 plugins/fish-spec/spec/expect.to_be_true.spec.fish delete mode 100644 plugins/fish-spec/spec/expect.to_contain_all.spec.fish delete mode 100644 plugins/fish-spec/spec/expect.to_equal.spec.fish delete mode 100644 plugins/fish-spec/spec/expect.to_not_contain_all.spec.fish delete mode 100644 plugins/fish-spec/spec/list.erase.spec.fish delete mode 100644 plugins/fish-spec/spec/spec.spec.fish delete mode 100644 plugins/omf/omf.fish delete mode 100644 plugins/omf/omf.git.fish delete mode 100644 plugins/omf/omf.helper.fish delete mode 100644 plugins/omf/omf.log.fish delete mode 100644 plugins/omf/omf.packages.fish delete mode 100644 plugins/omf/omf.packages.install.fish delete mode 100644 plugins/omf/omf.packages.update.fish delete mode 100644 plugins/omf/omf.remote.fish delete mode 100755 script/bootstrap.sh delete mode 100755 script/run-tests.fish delete mode 100644 spec/import.spec.fish delete mode 100755 spec/oh-my-fish.spec.fish delete mode 100644 templates/config.fish delete mode 100644 themes/.gitignore delete mode 100644 tools/install.fish diff --git a/.editorconfig b/.editorconfig index 551cef7..4593073 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,11 +1,9 @@ -# EditorConfig is awesome: http://EditorConfig.org - -# top-most EditorConfig file +# http://editorconfig.org root = true -# Two-space indent, Unix-style newlines, and a newline ending every file [*] end_of_line = lf -insert_final_newline = true -indent_style = space indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore index 11d5053..989e7cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,9 @@ -custom/* -plugins/* -themes/* +pkg/** +!pkg/omf +!pkg/omf/** -.DS_Store -*.pyc -*~ -*.sw? - -plugins/ta/data/* +themes/** +!themes/default/* -# Track oh-my-fish plugin -!plugins/omf/ +.DS_Store +**/.DS_Store diff --git a/.travis.yml b/.travis.yml index 01deb38..e321541 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,13 @@ language: c - os: - linux - - osx - -env: - - FISH_PPA=nightly-master BREW_OPTIONS=--HEAD - -before_install: - - script/bootstrap.sh - -script: script/run-tests.fish - -notifications: - email: - on_success: never - on_failure: change - webhooks: - urls: - - https://webhooks.gitter.im/e/16e8638d3a0deeaf317d - on_success: change - on_failure: always - on_start: false +sudo: false +addons: + apt: + packages: + - tree + - fish +before_script: pwd; tree -h +script: /bin/sh bin/install +after_script: + - cd ~/.config/fish; tree -h; find . -type f | xargs cat diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 037a2d2..31fbf99 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,36 +1,134 @@ +
+ + + +
+ +
+ +

+Issues +| +Packages +| +Commit Messages +| +Code Style +

+ # Contributing -We love pull requests. Here's a quick guide. +Thanks for taking the time to read this guide and please _do_ contribute to Oh My Fish. This is an open initiative and _everyone_ is welcome. :metal: + +## Issues + +Please [open an issue](https://github.com/fish-shell/omf/issues) for bug reports / patches. Include your OS version, code examples, stack traces and everything you can to help you debug your problem. + +If you have a new feature or large change in mind, please open a new issue with your suggestion to discuss the idea together. + +## Package Repositories + +This is the repository for the core Oh My Fish framework and bootstrap installer. + +If your issue is related to a specific package, we still may be able to help, but consider visiting that package's issue tracker first. + +## Commit Messages + ++ Use the [present tense](https://simple.wikipedia.org/wiki/Present_tense) ("add awesome-package" not "added ...") + ++ Less than 72 characters or less for the first line of your commit. + ++ Use of [emoji](http://www.emoji-cheat-sheet.com/) is definitely encouraged. :lollipop: + +## Code Style + +> These rules are not set in stone. Feel free to open an issue with suggestions and/or feedback. + +### Control Flow + +Using `if..else..end` blocks is preferred. + +```fish +if not set -q ENV_VARIABLE + set -g ENV_VARIABLE 42 +end +``` + +The following syntax is more concise, but arguably less transparent. + +> You still may use `and` / `or` statements if you consider `if..else..then` to be overkill. + +```fish +set -q VAR; set -g VAR 42 +``` + +### Functions + +Use named arguments `-a`: + +```fish +function greet -a message + echo "$message" +end +``` + +Use `-d` description fields: -Fork and make your change. Make sure the tests pass: +```fish +function greet -a message -d "Display a greeting message" + echo "$message" +end +``` - ./script/run-tests.fish -v +`fish` does not have private functions, so in order to avoid polluting the global namespace, use a prefix based in the scope of your code. For example, if you are writing a `ninja` plugin using `__ninja_function_name`. -Push to your fork and [submit a pull request][pr]. +If you are writing a function inside another function, prefix the inner one with the parent's name. -At this point you're waiting on us. We usually comment on pull requests within a few hours. We may suggest some changes or improvements or alternatives. +```fish +function parent + function parent_child + end +end +``` -Some things that will increase the chance that your pull request is accepted: +Note that it's still possible to mimic private functions in `fish` by deleting the function before returning using `functions -e function_name` -* Write tests. -* Follow our [style guide][style]. -* Write a [good commit message][commit]. +```fish +function public_func + function private_func + # ... + functions -e private_func + end +end +``` -## Style Guide +### Blocks -* Indentation should follow the "2-space convention". -* Keep line length to a maximum of 100 characters. +Blocks allow you to write code resembling macro expressions composed of smaller blocks without relying on variables. -### Plugins +Compare the following _without_ blocks: -If your plugin is complex, make sure to include tests, we suggest using [fish-spec][]. +```fish +set -l colors green1 green2 green3 +if test $error -ne 0 + set colors red1 red2 red3 +end -### Themes +for color in $colors + printf "%s"(set_color $color)">" +end +``` -Make sure to include a screenshot in your pull request, but don't commit the file to git. A nifty way is to post a comment with the image and link directly to it. +and _using_ blocks: +```fish +for color in (begin + if test $error -ne 0 + and printf "%s\n" red1 red2 red3 + or printf "%s\n" green1 green2 green3 + end) + printf "%s"(set_color $color)">" +end +``` -[pr]: https://github.com/oh-my-fish/oh-my-fish/compare/ -[fish-spec]: https://github.com/oh-my-fish/oh-my-fish/tree/master/plugins/fish-spec -[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html -[style]: #style-guide +The second example does not use a `colors` variable. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 278775a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM ubuntu:latest - -# Install dependencies -RUN apt-get -y install curl git software-properties-common - -# Set bootstrap script environment variables -ENV FISH_PPA=nightly-master \ - TRAVIS_OS_NAME=linux TRAVIS_REPO_SLUG=oh-my-fish/oh-my-fish TRAVIS_BRANCH=master - -# Cache script folder -ADD script /src/script - -# Install fish and oh-my-fish -RUN /src/script/bootstrap.sh - -WORKDIR /root/.oh-my-fish - -CMD ["fish", "./script/run-tests.fish", "--verbose"] diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 0000000..d4265cb --- /dev/null +++ b/FAQ.md @@ -0,0 +1,89 @@ +
+ + + +
+ +
+ +# FAQ + +Thanks for taking the time to read this FAQ. Feel free to create a new issue if your question is not answered here. + + +## What is Oh My Fish and why do I want it? + +Oh My Fish is a _framework_ for the [fishshell](https://fishshell.org). It helps you manage your configuration, themes and packages. + + +## What do I need to know to use Oh My Fish? + +_Nothing_. You can install Oh My Fish and keep using Fish as usual. When you are ready to learn more just type `wa help`. + + +## What are Oh My Fish packages? + +Oh My Fish packages are themes or plugins written in fish that extend the shell core functionality, run code during initialization, add auto completion for known utilities, etc. + + +## What kind of Oh My Fish packages are there? + +There are roughly 3 kinds of packages: + +1. Configuration utilities. For example [`pkg-pyenv`](https://github.com/oh-my-fish/pkg-pyenv) checks whether `pyenv` exists in your system and runs `(pyenv init - | psub)` for you during startup. + +2. Themes. Check our [theme gallery](https://github.com/oh-my-fish). + +3. Traditional shell utilities. For example [`pkg-copy`](https://github.com/oh-my-fish/pkg-copy), a clipboard utility compatible across Linux and OSX. + + +## What does Oh My Fish do exactly? + ++ Autoload installed packages and themes under `$OMF_PATH/`. + ++ Autoload your custom path. `$OMF_PATH/custom` by default, but configurable via `$OMF_CUSTOM`. + ++ Autoload any `functions` directory under `$OMF_PATH` and `$OMF_CUSTOM` + ++ Run `$OMF_CUSTOM/init.fish` if available. + + +## How can I upgrade from an existing Oh My Fish installation? + +> :warning: Remember to backup your dotfiles and other sensitive data first. + +``` +rm -rf "$fish_path" +curl -L git.io/omf | sh +``` + + +## I changed my prompt with `fish_config` and now I can't get my Oh My Fish theme's prompt back, what do I do? + +`fish_config` persists the prompt to `~/.config/fish/functions/fish_prompt.fish`. That file gets loaded _after_ the Oh My Fish theme, therefore it takes precedence over the Oh My Fish theme's prompt. To restore your Oh My Fish theme prompt, simply remove that file by running: + +``` +rm ~/.config/fish/functions/fish_prompt.fish +``` + + +## How do I use fish as my default shell? + +Add Fish to `/etc/shells`: + +```sh +echo "/usr/local/bin/fish" | sudo tee -a /etc/shells +``` + +Make Fish your default shell: + +```sh +chsh -s /usr/local/bin/fish +``` + +To switch your default shell back: +> Substitute `/bin/bash` with `/bin/tcsh` or `/bin/zsh` as appropriate. + +```sh +chsh -s /bin/bash +``` diff --git a/LICENSE b/LICENSE index a439b2e..288be38 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Bruno Ferreira Pinto +Copyright (c) 2015, Oh My Fish! Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 214cfd4..615b90f 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,243 @@ +> The [Fishshell][fishshell] Framework + +[![Fish Version][fish-badge]][fishshell] +[![Build Status][travis-badge]][travis-url] +[![License][license-badge]](#LICENSE) + + + +
+

- - - + + +

- +
+ +

+About +| +Install +| +Getting Started +| +Advanced +| +Screencasts +| +Contributing +| +FAQ + +

+ + + +

+

-[![Build Status](https://travis-ci.org/oh-my-fish/oh-my-fish.svg?branch=master)](https://travis-ci.org/oh-my-fish/oh-my-fish) [![](https://img.shields.io/badge/Framework-Oh My Fish-blue.svg?style=flat)](https://github.com/oh-my-fish/oh-my-fish) ![](https://img.shields.io/cocoapods/l/AFNetworking.svg) [![Join the chat at https://gitter.im/oh-my-fish/oh-my-fish](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/oh-my-fish/oh-my-fish?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +
+# About -# Oh My Fish! +> :warning: You need [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) +and [Fish][fishshell] to install Oh My Fish!. -### Why? - Developing on a shell should be a pleasure. Our goal is to help developers that do not want to spend time configuring their own computer to spend time doing what they want. +Oh My Fish is an all-purpose framework for the [fishshell][Fishshell]. It looks after your configuration, themes and packages. It's lightining fast and easy to use. -### How? - With the power of our community, we take the already awesome [fish shell][fish] to another level by creating simple-to-use plugins and themes. +We love contributions, [fork and send us a PR](https://github.com/fish-shell/omf/fork). -[fish]: http://fishshell.com/ +# Install -### What? - Oh-my-fish is a user-friendly framework for managing your fish-shell configuration. It includes optional plugins (brew, git-flow, rails, python, node, etc) and themes. +```sh +curl -L git.io/omf | sh +omf help +``` -
-## Installation +Or _download_ and run it yourself: + +```sh +curl -L git.io/omf > install +chmod +x install +./install +``` + +# :beginner: Getting Started + +Oh My Fish includes a small utility `omf` to fetch and install new packages and themes. + +## `omf update` + +Update framework and installed packages. + +## `omf get` _` ...`_ + +Install one _or more_ themes or packages. To list available packages type `omf use`. + +> You can fetch packages by URL as well via `omf get URL` + +## `omf list` + +List installed packages. + +> To list packages available for download use `omf get`. + +## `omf use` _``_ + +Apply a theme. To list available themes type `omf use`. + +## `omf remove` _``_ + +Remove a theme or package. + +> Packages subscribed to `uninstall_` events are notified before the package is removed to allow custom cleanup of resources. See [Uninstall](#uninstall). + +## `omf new pkg | theme` _``_ + +Scaffold out a new package or theme. + +> This creates a new directory under `$OMF_CUSTOM/{pkg | themes}/` with a template. + +## `omf submit` _`pkg/`_ _`[]`_ + +Add a new package. To add a theme use `omf submit` _`themes/`_ _``_. + +Make sure to [send us a PR][omf-pulls-link] to update the registry. + +## `omf query` _``_ + +Use to inspect all session variables. Useful to dump _path_ variables like `$fish_function_path`, `$fish_complete_path`, `$PATH`, etc. + +## `omf destroy` + +Uninstall Oh My Fish. See [uninstall](#uninstall) for more information. + +# :triangular_flag_on_post: Advanced ++ [Bootstrap](#bootstrap) ++ [Startup](#startup) ++ [Core Library](#core-library) ++ [Packages](#packages) + + [Creating](#creating) + + [Submitting](#submitting) + + [Initialization](#initialization) + + [Uninstall](#uninstall) + + [Ignoring](#ignoring) + +## Bootstrap + +Oh My Fish's bootstrap script will install `git` and `fish` if not available, switch your default shell and modify `$HOME/.config/fish/config.fish` to source Oh My Fish's `init.fish` script. + +## Startup + +This script runs each time a new session begins, autoloading packages, themes and your _custom_ path (dotfiles) in that order. + +The _custom_ path (`$HOME/.dotfiles` by default) is defined by `$OMF_CUSTOM` in `$HOME/.config/fish/config.fish`. Modify this to load your own dotfiles if you have any. + +## Core Library + +The core library is a minimum set of basic utility functions that extend your shell. + ++ [See the documentation](/lib/README.md). + + +## Packages + +### Creating + +> A package name may only contain lowercase letters and hyphens to separate words. + +To scaffold out a new package: ```fish -curl -L https://github.com/oh-my-fish/oh-my-fish/raw/master/tools/install.fish | fish +$ omf new pkg my_package + +my_package/ + README.md + my_package.fish + completions/my_package.fish ``` -**NOTE**: The installation script renames your existing `config.fish` to `config.orig`, and replaces it with [the default oh-my-fish config](https://github.com/oh-my-fish/oh-my-fish/blob/master/templates/config.fish). If you have existing customizations to your fish config, you will need to manually include those customizations after the install. +> Use `omf new theme my_theme` for themes. + +Please provide [auto completion](http://fishshell.com/docs/current/commands.html#complete) for your utilities if applicable and describe how your package works in the `README.md`. -If you want to install it manually, [click here](https://github.com/oh-my-fish/oh-my-fish/wiki/Manual-Installation). -## Usage +`my_package.fish` defines a single function: + +```fish +function my_package -d "My package" +end +``` -Open your fish configuration file `~/.config/fish/config.fish` and specify the theme and the plugins you want to use. And then run `omf install` on your terminal to install them. +> Bear in mind that fish lacks a private scope so consider the following options to avoid polluting the global namespace: -Before setting down on a theme, you might want to have a go with all themes using our quick [theme switcher](https://github.com/oh-my-fish/plugin-theme) by typing `theme --help` on your shell. ++ Prefix functions: `my_package_my_func`. ++ Using [blocks](http://fishshell.com/docs/current/commands.html#block). -## Upgrading from previous version -[![asciicast](https://asciinema.org/a/20802.png)](https://asciinema.org/a/20802) +### Submitting + +Oh My Fish keeps a registry of packages under `$OMF_PATH/db/`. + +To create a new entry run: + +```fish +omf submit pkg/my_package .../my_package.git +``` -## Customization +Similarly for themes use: + +```fish +omf submit theme/my_theme .../my_theme.git +``` + +This will add a new entry to your local copy of the registry. Please [send us a PR][omf-pulls-link] to update the global registry. + + +### Initialization + +If you want to be [notified](http://fishshell.com/docs/current/commands.html#emit) when your package is loads, declare the following function in your `my_package.fish`: + +```fish +function init -a path --on-event init_mypkg +end +``` + +Use this event to modify the environment, load resources, autoload functions, etc. If your package does not export any functions, you can still use this event to add functionality to your package. + +### Uninstall + +Oh My Fish emits `uninstall_` events before a package is removed via `omf remove `. Subscribers can use the event to clean up custom resources, etc. + +```fish +function uninstall --on-event uninstall_pkg +end +``` + +### Ignoring + +Remove any packages you wish to turn off using `omf remove `. Alternatively, you can set a global env variable `$OMF_IGNORE` in your `~/.config/fish/config.fish` with the packages you wish to ignore. For example: + +```fish +set -g OMF_IGNORE skip this that ... +``` -If you have many functions which go well together, you can create custom plugin in the `custom/plugins/PLUGIN_NAME` directory and add to it as many functions as you want. -If you would like to use your custom theme, move it with the same name in the `custom/themes/` directory and it will override the original theme in `themes/`. +# License -If you just want to override any of the default behavior or add some environment variables, just add a new file (ending in .load) into the `custom/` directory. +MIT © [Oh My Fish][contributors] :metal: -## Contributing +[fishshell]: http://fishshell.com -Create an [issue](https://github.com/oh-my-fish/oh-my-fish/issues) linking to your repository and we will move it to the [oh-my-fish](https://github.com/oh-my-fish) organization. +[contributors]: https://github.com/fish-shell/omf/graphs/contributors -## Uninstall +[travis-badge]: http://img.shields.io/travis/fish-shell/omf.svg?style=flat-square +[travis-url]: https://travis-ci.org/fish-shell/omf - rm -rf ~/.oh-my-fish - -## License +[fish-badge]: https://img.shields.io/badge/fish-v2.2.0-007EC7.svg?style=flat-square -[MIT](http://mit-license.org) © [Contributors](https://github.com/oh-my-fish/oh-my-fish/graphs/contributors) +[license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square -[Logo](https://cloud.githubusercontent.com/assets/958723/6847746/8d1b95b0-d3a7-11e4-866a-6bdc1eea0fe6.png) by [marcker](https://github.com/marcker):small_blue_diamond: [Attribution CC 4.0](http://creativecommons.org/licenses/by/4.0/) +[omf-pulls-link]: https://github.com/fish-shell/omf/pulls diff --git a/bin/install b/bin/install new file mode 100755 index 0000000..2776bbf --- /dev/null +++ b/bin/install @@ -0,0 +1,120 @@ +#!/bin/sh +# +# USAGE +# #1: curl -L git.io/omf | sh +# #2: curl -L git.io/omf > install && chmod +x install && ./install +# #3: OMF_CUSTOM=~/.dotfiles curl -L git.io/omf | sh +# +# ENV +# XDG_DATA_HOME Base directory (~/.local/share) +# XDG_CONFIG_HOME Base configuration directory (~/.config) +# +# ↑ See XDG Base Directory Specification +# → https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +# +# OMF_PATH Oh My Fish directory +# OMF_CONFIG Oh My Fish configuration +# OMF_CUSTOM Custom dotfiles directory +# +# OMF_REPO_URI Source git repository +# OMF_REPO_BRANCH Source repository default branch (master) +# +# FUNCTIONS +# die +# is_installed +# omf_create_fish_config +# omf_install + +test -z ${XDG_DATA_HOME+_} && XDG_DATA_HOME="${HOME}/.local/share" +test -z ${XDG_CONFIG_HOME+_} && XDG_CONFIG_HOME="${HOME}/.config" + +test -z ${OMF_PATH+_} && OMF_PATH="${XDG_DATA_HOME}/omf" +test -z ${OMF_CUSTOM+_} && OMF_CUSTOM="${HOME}/.dotfiles" +test -z ${OMF_CONFIG+_} && OMF_CONFIG="${XDG_CONFIG_HOME}/omf" + +test -z ${OMF_REPO_URI+_} && OMF_REPO_URI="https://github.com/fish-shell/omf" +test -z ${OMF_REPO_BRANCH+_} && OMF_REPO_BRANCH="master" + +die() { + echo "$1" && exit 1 +} + +is_installed() { + type "$1" >/dev/null 2>&1 +} + +omf_create_fish_config() { + local fish_config_file=$1 + mkdir -p $(dirname "${fish_config_file}") + touch "${fish_config_file}" +} + +omf_install() { + echo "Resolving Oh My Fish path → ${OMF_PATH}" + test -d "${OMF_PATH}" && die "Existing installation detected, aborting" + local git_uri="$(echo ${OMF_REPO_URI} | sed 's/\.git//').git" + + echo "Cloning Oh My Fish → ${git_uri}" + if ! git clone -q --depth 1 -b "${OMF_REPO_BRANCH}" "${git_uri}" "${OMF_PATH}"; then + echo "Is 'git' installed?" + die "Could not clone the repository → ${OMF_PATH}:${OMF_REPO_BRANCH}" + fi + + pushd ${OMF_PATH} >/dev/null 2>&1 + + local git_rev=$(git rev-parse HEAD) >/dev/null 2>&1 + local git_upstream=$(git config remote.upstream.url) + + if [ -z "${git_upstream}" ]; then + git remote add upstream ${git_uri} + else + git remote set-url upstream ${git_uri} + fi + + echo "Oh My Fish revision id → ${git_rev}" + popd >/dev/null 2>&1 + test -z ${FISH_CONFIG+_} && FISH_CONFIG="${XDG_CONFIG_HOME}/fish" + + local fish_config_file="${FISH_CONFIG}/config.fish" + + if [ -e "${FISH_CONFIG}/config.fish" ]; then + local timestamp=$(date +%s) + local fish_config_bk="${FISH_CONFIG}/config.${timestamp}.copy" + + echo "Found existing 'fish' configuration → ${fish_config_file}" + echo "Writing back-up copy → ${fish_config_bk}" + + cp "${fish_config_file}" "${fish_config_bk}" >/dev/null 2>&1 + test $? -ne 0 && die "Writing back-up copy failed, error code → ${?}" + else + omf_create_fish_config $fish_config_file + fi + + echo "Adding Oh My Fish bootstrap → ${fish_config_file}" + touch ${fish_config_file} >/dev/null 2>&1 + test ! -w ${fish_config_file} && die "Fish configuration file is not writable, aborting." + + + echo "set -g OMF_PATH $(echo "${OMF_PATH}" | sed -e "s|$HOME|\$HOME|")" > ${fish_config_file} + echo "set -g OMF_CUSTOM $(echo "${OMF_CUSTOM}" | sed -e "s|$HOME|\$HOME|")" >> ${fish_config_file} + echo "set -g OMF_CONFIG $(echo "${OMF_CONFIG}" | sed -e "s|$HOME|\$HOME|")" >> ${fish_config_file} + echo "source \$OMF_PATH/init.fish" >> ${fish_config_file} + + if [ ! -d "${OMF_CONFIG}" ]; then + echo "Writing Oh My Fish configuration → ${OMF_CONFIG}" + mkdir -p "${OMF_CONFIG}" + test -f "${OMF_CONFIG}/theme" || echo default > "${OMF_CONFIG}/theme" + test -f "${OMF_CONFIG}/revision" || echo ${git_rev} > "${OMF_CONFIG}/revision" + fi +} + +echo "Installing Oh My Fish..." +! is_installed "fish" && die "Please install fish to continue → http://fishshell.com/" +if omf_install; then + echo "Oh My Fish successfully installed." + cd $HOME + # Do not swap process if running in a CI environment. + [ -z ${CI+_} ] || exit 0 && exec "fish" < /dev/tty +else + die "Oh My Fish couldn't install, but you can complain here → git.io/omf-issues" +fi diff --git a/custom/example.load b/custom/example.load deleted file mode 100644 index 3445324..0000000 --- a/custom/example.load +++ /dev/null @@ -1,5 +0,0 @@ -# Add yourself some shortcuts to projects you often work on -# Example: -# -# set oh-my-fish /Users/bpinto/.oh-my-fish -# diff --git a/custom/plugins/example/completions/example.fish b/custom/plugins/example/completions/example.fish deleted file mode 100644 index 9733505..0000000 --- a/custom/plugins/example/completions/example.fish +++ /dev/null @@ -1,2 +0,0 @@ -# Optionally add completions for your plugin here. -# complete -f -c my_command -a some_arg -d 'Description here' diff --git a/custom/plugins/example/example.fish b/custom/plugins/example/example.fish deleted file mode 100644 index 406f274..0000000 --- a/custom/plugins/example/example.fish +++ /dev/null @@ -1,2 +0,0 @@ -# Add your own custom plugins in the custom/plugins directory. Plugins placed -# here will override ones with the same name in the main plugins directory. diff --git a/db/pkg/ansible b/db/pkg/ansible new file mode 100644 index 0000000..7954220 --- /dev/null +++ b/db/pkg/ansible @@ -0,0 +1 @@ +https://github.com/wa/pkg-ansible diff --git a/db/pkg/battery b/db/pkg/battery new file mode 100644 index 0000000..9db9f44 --- /dev/null +++ b/db/pkg/battery @@ -0,0 +1 @@ +https://github.com/wa/pkg-battery diff --git a/db/pkg/copy b/db/pkg/copy new file mode 100644 index 0000000..877c27d --- /dev/null +++ b/db/pkg/copy @@ -0,0 +1 @@ +https://github.com/wa/pkg-copy diff --git a/db/pkg/direnv b/db/pkg/direnv new file mode 100644 index 0000000..c47ed5f --- /dev/null +++ b/db/pkg/direnv @@ -0,0 +1 @@ +https://github.com/wa/pkg-direnv diff --git a/db/pkg/emacs b/db/pkg/emacs new file mode 100644 index 0000000..ce49ec5 --- /dev/null +++ b/db/pkg/emacs @@ -0,0 +1 @@ +https://github.com/cap10morgan/wa-emacs diff --git a/db/pkg/extract b/db/pkg/extract new file mode 100644 index 0000000..7de9aaf --- /dev/null +++ b/db/pkg/extract @@ -0,0 +1 @@ +https://github.com/wa/pkg-extract diff --git a/db/pkg/fasd b/db/pkg/fasd new file mode 100644 index 0000000..2be4be5 --- /dev/null +++ b/db/pkg/fasd @@ -0,0 +1 @@ +https://github.com/wa/pkg-fasd diff --git a/db/pkg/gi b/db/pkg/gi new file mode 100644 index 0000000..78e91ee --- /dev/null +++ b/db/pkg/gi @@ -0,0 +1 @@ +https://github.com/wa/pkg-gi diff --git a/db/pkg/hub b/db/pkg/hub new file mode 100644 index 0000000..580f5a1 --- /dev/null +++ b/db/pkg/hub @@ -0,0 +1 @@ +https://github.com/wa/pkg-hub diff --git a/db/pkg/keychain b/db/pkg/keychain new file mode 100644 index 0000000..092efd5 --- /dev/null +++ b/db/pkg/keychain @@ -0,0 +1 @@ +https://github.com/wa/pkg-keychain diff --git a/db/pkg/limap b/db/pkg/limap new file mode 100644 index 0000000..7fe58e9 --- /dev/null +++ b/db/pkg/limap @@ -0,0 +1 @@ +https://github.com/wa/pkg-limap diff --git a/db/pkg/osx_manpath b/db/pkg/osx_manpath new file mode 100644 index 0000000..0d254ad --- /dev/null +++ b/db/pkg/osx_manpath @@ -0,0 +1 @@ +https://github.com/wa/pkg-osx_manpath diff --git a/db/pkg/peco b/db/pkg/peco new file mode 100644 index 0000000..e8d6f59 --- /dev/null +++ b/db/pkg/peco @@ -0,0 +1 @@ +https://github.com/wa/pkg-peco diff --git a/db/pkg/pyenv b/db/pkg/pyenv new file mode 100644 index 0000000..6f22723 --- /dev/null +++ b/db/pkg/pyenv @@ -0,0 +1 @@ +https://github.com/wa/pkg-pyenv diff --git a/db/pkg/rbenv b/db/pkg/rbenv new file mode 100644 index 0000000..43cfe4a --- /dev/null +++ b/db/pkg/rbenv @@ -0,0 +1 @@ +https://github.com/wa/pkg-rbenv diff --git a/db/pkg/set_color b/db/pkg/set_color new file mode 100644 index 0000000..dde23ba --- /dev/null +++ b/db/pkg/set_color @@ -0,0 +1 @@ +https://github.com/wa/pkg-set_color diff --git a/db/pkg/stamp b/db/pkg/stamp new file mode 100644 index 0000000..04a9de4 --- /dev/null +++ b/db/pkg/stamp @@ -0,0 +1 @@ +https://github.com/wa/pkg-stamp diff --git a/db/pkg/thefuck b/db/pkg/thefuck new file mode 100644 index 0000000..4016576 --- /dev/null +++ b/db/pkg/thefuck @@ -0,0 +1 @@ +https://github.com/wa/pkg-thefuck diff --git a/db/pkg/tiny b/db/pkg/tiny new file mode 100644 index 0000000..245b30f --- /dev/null +++ b/db/pkg/tiny @@ -0,0 +1 @@ +https://github.com/wa/pkg-tiny diff --git a/db/themes/agnoster b/db/themes/agnoster new file mode 100644 index 0000000..448d3b9 --- /dev/null +++ b/db/themes/agnoster @@ -0,0 +1 @@ +https://github.com/wa/theme-agnoster diff --git a/db/themes/agnoster copy b/db/themes/agnoster copy new file mode 100644 index 0000000..9f8f676 --- /dev/null +++ b/db/themes/agnoster copy @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-agnoster diff --git a/db/themes/agnoster-mercurial b/db/themes/agnoster-mercurial new file mode 100644 index 0000000..d8326c0 --- /dev/null +++ b/db/themes/agnoster-mercurial @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-agnoster-mercurial diff --git a/db/themes/batman b/db/themes/batman new file mode 100644 index 0000000..a4c4e4d --- /dev/null +++ b/db/themes/batman @@ -0,0 +1 @@ +https://github.com/wa/theme-batman diff --git a/db/themes/beloglazov b/db/themes/beloglazov new file mode 100644 index 0000000..9407759 --- /dev/null +++ b/db/themes/beloglazov @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-beloglazov diff --git a/db/themes/bira b/db/themes/bira new file mode 100644 index 0000000..8b3bb19 --- /dev/null +++ b/db/themes/bira @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-bira diff --git a/db/themes/bobthefish b/db/themes/bobthefish new file mode 100644 index 0000000..fcef7f8 --- /dev/null +++ b/db/themes/bobthefish @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-bobthefish diff --git a/db/themes/budspencer b/db/themes/budspencer new file mode 100644 index 0000000..0b09a56 --- /dev/null +++ b/db/themes/budspencer @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-budspencer diff --git a/db/themes/cbjohnson b/db/themes/cbjohnson new file mode 100644 index 0000000..0895574 --- /dev/null +++ b/db/themes/cbjohnson @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-cbjohnson diff --git a/db/themes/clearance b/db/themes/clearance new file mode 100644 index 0000000..7e2e3d2 --- /dev/null +++ b/db/themes/clearance @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-clearance diff --git a/db/themes/cmorrell b/db/themes/cmorrell new file mode 100644 index 0000000..3bf7aea --- /dev/null +++ b/db/themes/cmorrell @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-cmorrell diff --git a/db/themes/coffeeandcode b/db/themes/coffeeandcode new file mode 100644 index 0000000..ed7794e --- /dev/null +++ b/db/themes/coffeeandcode @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-coffeeandcode diff --git a/db/themes/cor b/db/themes/cor new file mode 100644 index 0000000..c5f2d0c --- /dev/null +++ b/db/themes/cor @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-cor diff --git a/db/themes/dangerous b/db/themes/dangerous new file mode 100644 index 0000000..232befc --- /dev/null +++ b/db/themes/dangerous @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-dangerous diff --git a/db/themes/eclm b/db/themes/eclm new file mode 100644 index 0000000..a117eaf --- /dev/null +++ b/db/themes/eclm @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-eclm diff --git a/db/themes/edan b/db/themes/edan new file mode 100644 index 0000000..b6a557f --- /dev/null +++ b/db/themes/edan @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-edan diff --git a/db/themes/fishface b/db/themes/fishface new file mode 100644 index 0000000..7d98ca4 --- /dev/null +++ b/db/themes/fishface @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-fishface diff --git a/db/themes/fishy-drupal b/db/themes/fishy-drupal new file mode 100644 index 0000000..7af60ac --- /dev/null +++ b/db/themes/fishy-drupal @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-fishy-drupal diff --git a/db/themes/fisk b/db/themes/fisk new file mode 100644 index 0000000..523c39a --- /dev/null +++ b/db/themes/fisk @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-fisk diff --git a/db/themes/flash b/db/themes/flash new file mode 100644 index 0000000..3231254 --- /dev/null +++ b/db/themes/flash @@ -0,0 +1 @@ +https://github.com/wa/theme-flash diff --git a/db/themes/fox b/db/themes/fox new file mode 100644 index 0000000..cd61ce9 --- /dev/null +++ b/db/themes/fox @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-fox diff --git a/db/themes/gianu b/db/themes/gianu new file mode 100644 index 0000000..a663ed4 --- /dev/null +++ b/db/themes/gianu @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-gianu diff --git a/db/themes/gitstatus b/db/themes/gitstatus new file mode 100644 index 0000000..58f2438 --- /dev/null +++ b/db/themes/gitstatus @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-gitstatus diff --git a/db/themes/gnuykeaj b/db/themes/gnuykeaj new file mode 100644 index 0000000..90eb711 --- /dev/null +++ b/db/themes/gnuykeaj @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-gnuykeaj diff --git a/db/themes/godfather b/db/themes/godfather new file mode 100644 index 0000000..6cab30a --- /dev/null +++ b/db/themes/godfather @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-godfather diff --git a/db/themes/hogan b/db/themes/hogan new file mode 100644 index 0000000..bdb2642 --- /dev/null +++ b/db/themes/hogan @@ -0,0 +1 @@ +https://github.com/wa/theme-hogan diff --git a/db/themes/hulk b/db/themes/hulk new file mode 100644 index 0000000..c469b47 --- /dev/null +++ b/db/themes/hulk @@ -0,0 +1 @@ +https://github.com/wa/theme-hulk diff --git a/db/themes/idan b/db/themes/idan new file mode 100644 index 0000000..22a5bd4 --- /dev/null +++ b/db/themes/idan @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-idan diff --git a/db/themes/integral b/db/themes/integral new file mode 100644 index 0000000..43d76b1 --- /dev/null +++ b/db/themes/integral @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-integral diff --git a/db/themes/jacaetevha b/db/themes/jacaetevha new file mode 100644 index 0000000..95e0e85 --- /dev/null +++ b/db/themes/jacaetevha @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-jacaetevha diff --git a/db/themes/krisleech b/db/themes/krisleech new file mode 100644 index 0000000..80a5378 --- /dev/null +++ b/db/themes/krisleech @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-krisleech diff --git a/db/themes/l b/db/themes/l new file mode 100644 index 0000000..ff4c88c --- /dev/null +++ b/db/themes/l @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-l diff --git a/db/themes/led b/db/themes/led new file mode 100644 index 0000000..97eec2b --- /dev/null +++ b/db/themes/led @@ -0,0 +1 @@ +https://github.com/wa/theme-led diff --git a/db/themes/mtahmed b/db/themes/mtahmed new file mode 100644 index 0000000..a0d61e6 --- /dev/null +++ b/db/themes/mtahmed @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-mtahmed diff --git a/db/themes/nai b/db/themes/nai new file mode 100644 index 0000000..dc1a1b4 --- /dev/null +++ b/db/themes/nai @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-nai diff --git a/db/themes/numist b/db/themes/numist new file mode 100644 index 0000000..0545759 --- /dev/null +++ b/db/themes/numist @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-numist diff --git a/db/themes/ocean b/db/themes/ocean new file mode 100644 index 0000000..bb0d22d --- /dev/null +++ b/db/themes/ocean @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-ocean diff --git a/db/themes/perryh b/db/themes/perryh new file mode 100644 index 0000000..215371f --- /dev/null +++ b/db/themes/perryh @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-perryh diff --git a/db/themes/red-snapper b/db/themes/red-snapper new file mode 100644 index 0000000..2dea693 --- /dev/null +++ b/db/themes/red-snapper @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-red-snapper diff --git a/db/themes/robbyrussell b/db/themes/robbyrussell new file mode 100644 index 0000000..b25ff0a --- /dev/null +++ b/db/themes/robbyrussell @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-robbyrussell diff --git a/db/themes/russell b/db/themes/russell new file mode 100644 index 0000000..f326949 --- /dev/null +++ b/db/themes/russell @@ -0,0 +1 @@ +https://github.com/wa/theme-russell diff --git a/db/themes/scorphish b/db/themes/scorphish new file mode 100644 index 0000000..005b7d5 --- /dev/null +++ b/db/themes/scorphish @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-scorphish diff --git a/db/themes/simplevi b/db/themes/simplevi new file mode 100644 index 0000000..5662f6c --- /dev/null +++ b/db/themes/simplevi @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-simplevi diff --git a/db/themes/syl20bnr b/db/themes/syl20bnr new file mode 100644 index 0000000..f359c55 --- /dev/null +++ b/db/themes/syl20bnr @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-syl20bnr diff --git a/db/themes/taktoa b/db/themes/taktoa new file mode 100644 index 0000000..b223353 --- /dev/null +++ b/db/themes/taktoa @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-taktoa diff --git a/db/themes/technopagan b/db/themes/technopagan new file mode 100644 index 0000000..aad8b09 --- /dev/null +++ b/db/themes/technopagan @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-technopagan diff --git a/db/themes/toaster b/db/themes/toaster new file mode 100644 index 0000000..e24cf5e --- /dev/null +++ b/db/themes/toaster @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-toaster diff --git a/db/themes/tomita b/db/themes/tomita new file mode 100644 index 0000000..4989c01 --- /dev/null +++ b/db/themes/tomita @@ -0,0 +1 @@ +https://github.com/daveyarwood/tomita diff --git a/db/themes/trout b/db/themes/trout new file mode 100644 index 0000000..883698d --- /dev/null +++ b/db/themes/trout @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-trout diff --git a/db/themes/uggedal b/db/themes/uggedal new file mode 100644 index 0000000..c07b23f --- /dev/null +++ b/db/themes/uggedal @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-uggedal diff --git a/db/themes/will b/db/themes/will new file mode 100644 index 0000000..9f75ba3 --- /dev/null +++ b/db/themes/will @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-will diff --git a/db/themes/yimmy b/db/themes/yimmy new file mode 100644 index 0000000..9bd4f45 --- /dev/null +++ b/db/themes/yimmy @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-yimmy diff --git a/db/themes/zish b/db/themes/zish new file mode 100644 index 0000000..ebc455b --- /dev/null +++ b/db/themes/zish @@ -0,0 +1 @@ +https://github.com/oh-my-fish/theme-zish diff --git a/functions/Plugin.fish b/functions/Plugin.fish deleted file mode 100644 index 85a86ab..0000000 --- a/functions/Plugin.fish +++ /dev/null @@ -1,11 +0,0 @@ -function Plugin --argument-names name - set -g fish_plugins $fish_plugins $name - - if [ -e $fish_path/plugins/$name -o -e $fish_custom/plugins/$name ] - import plugins/$name - else - set_color red - echo "Plugin '$name' is not installed. Run 'omf install' to download and install it." - set_color normal - end -end diff --git a/functions/Theme.fish b/functions/Theme.fish deleted file mode 100644 index ec316d4..0000000 --- a/functions/Theme.fish +++ /dev/null @@ -1,11 +0,0 @@ -function Theme --argument-names name - set -g fish_theme $name - - if [ -e $fish_path/themes/$name -o -e $fish_custom/themes/$name ] - import themes/$name - else - set_color red - echo "Theme '$name' is not installed. Run 'omf install' to download and install it." - set_color normal - end -end diff --git a/functions/_prepend_path.fish b/functions/_prepend_path.fish deleted file mode 100644 index f798c2c..0000000 --- a/functions/_prepend_path.fish +++ /dev/null @@ -1,48 +0,0 @@ -# NAME -# _prepend_path - adds a path to a list -# -# SYNOPSIS -# _prepend_path [-d --destination ] -# -# DESCRIPTION -# Adds a path to a list. -# If no list specified, defaults to $PATH -# -# OPTIONS -# -# Required. Specify the path to add to the list. - -# OPERATORS -# -d -# Should appear at the end if used. Specifies the name of the -# list to prepend the paths to. -# If not used, $PATH is assumed by default. -# -# EXAMPLES -# _prepend_path $path -# Add $path to $PATH -# -# _prepend_path $path -d $fish_function_path -# Add $path to $fish_function_path -#/ -function _prepend_path - # $PATH is the default destination path - set -l destination_path PATH - set -l path $argv - - if test (count $argv) -gt 2 - switch $path[-2] - case -d --destination - set destination_path $path[-1] - set path $path[1..-3] - end - end - - for path in $path - if test -d $path - if not contains $path $$destination_path - set $destination_path $path $$destination_path - end - end - end -end diff --git a/functions/_prepend_tree.fish b/functions/_prepend_tree.fish deleted file mode 100644 index 230bf14..0000000 --- a/functions/_prepend_tree.fish +++ /dev/null @@ -1,105 +0,0 @@ -# NAME -# _prepend_tree - add a dependency tree to fish_function_path -# -# SYNOPSIS -# _prepend_tree [-v --verbose] [..] -# -# DESCRIPTION -# Search a path tree and prepend directories with fish files. Use a glob -# list to include or exclude other file extensions. Use -v --verbose to -# output directories to be added to the path. -# -# OPTIONS -# [-v --verbose] -# Optional. Print directories that match the glob. Must be the -# first argument if used. -# -# -# Required. Specify the path to search for glob patterns. -# -# [ [ ..]] -# Glob pattern to match when traversing the path path. -# -# OPERATORS -# [! -not glob] -# Negates the following glob. -# -# [ -o -or ..] -# Default. Must meet at least one listed criteria. -# -# [ [-a -and ..]] -# Must meet *all* listed criteria. -# -# EXAMPLES -# _prepend_tree $path -# Match directories in $path containing `.fish` files. -# -# _prepend_tree $path \*.fish \*.sh -# Match directories in $path with either `.fish` OR `.sh` files. -# -# _prepend_tree $path \*.fish -a ! _\*.\* -# Match directories with `.fish` files that do not start with `_`. -# -# AUTHORS -# Jorge Bucaran -# -# SEE ALSO -# .oh-my-fish/functions/_prepend_path.fish -# -# v.0.2.0 -#/ -function _prepend_tree -d "Add a dependency tree to the Fish path." - # Match directories with .fish files always. - set -l glob -name \*.fish - set -l verbose "" - - # Retrieve first argument, either the path or the -v option. - set -l path $argv[1] - if contains -- $path -v --verbose - set verbose -v - # Option first, path should be next. - set path $argv[2] - end - - # Parse glob options to create the main glob pattern. - if [ (count $argv) -gt 2 ] - set -l operator -o - for option in $argv[3..-1] - switch $option - case ! -not - set operator $operator ! - case -o -or - set operator -o - case -a -and - set operator -a - case "*" - if [ operator = ! ] - set glob $operator $glob - else - set glob $glob $operator - end - set glob $glob -name $option - set operator -o # Default - end - end - end - - # Traverse $path prepending only directories with matches. Excludes completions folder. - test -d $path - and for dir in (find $path ! -name "completions" ! -path "*.git*" -type d) - # Use head to retrieve at least one match. Skip not found errors - # for directories that do not exist. - if [ -z (find "$dir" $glob -maxdepth 1 ^/dev/null | head -1) ] - continue - end - - # Print matched directories if the -v option is set. - if not [ -z $verbose ] - printf "%s\n" $dir - end - - # Prepend matched directory to the the global fish function path. - # Note path duplicates are already handled by _prepend_path. - _prepend_path $dir -d fish_function_path - end -end diff --git a/functions/import.fish b/functions/import.fish deleted file mode 100644 index 05bc1db..0000000 --- a/functions/import.fish +++ /dev/null @@ -1,53 +0,0 @@ -# NAME -# import - load libraries, plugins, themes, etc. -# -# SYNOPSIS -# import [..] -# -# DESCRIPTION -# Import libraries, plugins, themes, completions. Prepend existing -# user custom/ directories to the path to allow users to -# override specific functions in themes/plugins. -# -# NOTES -# $fish_path and $fish_custom point to oh-my-fish home and the user -# dotfiles folder respectively. Both globals are usually configured -# in ~/.config/fish/config.fish. Also, import is clever enough to -# skip directories with *.spec.fish files. -# -# EXAMPLES -# import plugins/ -# import plugins/{dpaste,cask} themes/bobthefish -# -# AUTHORS -# Jorge Bucaran -# -# SEE ALSO -# functions/_prepend_path.fish -# functions/_prepend_tree.fish -# -# v.0.1.1 -#/ -function import -d "Load libraries, plugins, themes, etc." - # Do not add spec files to function path. - set -l skip_spec \*.fish -a ! \*.spec.fish - - for library in $argv - # Prepend plugins, themes and completions, traversing library - # trees and prepending directories with fish code. - _prepend_tree $fish_path/$library $skip_spec - _prepend_tree $fish_custom/$library $skip_spec - _prepend_path $fish_path/$library/completions -d fish_complete_path - _prepend_path $fish_custom/$library/completions -d fish_complete_path - - # Set path to load files. - set -l path $library/(basename $library).load - - # Source each plugin, theme, etc., configuration load file. - for load in $fish_path/$path $fish_custom/$path - if [ -e $load ] - . $load - end - end - end -end diff --git a/functions/restore_original_fish_colors.fish b/functions/restore_original_fish_colors.fish deleted file mode 100644 index a33cf84..0000000 --- a/functions/restore_original_fish_colors.fish +++ /dev/null @@ -1,29 +0,0 @@ -function restore_original_fish_colors - # Regular syntax highlighting colors - set fish_color_normal normal - set fish_color_command 005fd7 purple - set fish_color_param 00afff cyan - set fish_color_redirection normal - set fish_color_comment red - set fish_color_error red --bold - set fish_color_escape cyan - set fish_color_operator cyan - set fish_color_quote brown - set fish_color_autosuggestion 555 yellow - set fish_color_valid_path --underline - - set fish_color_cwd green - set fish_color_cwd_root red - - # Background color for matching quotes and parenthesis - set fish_color_match cyan - - # Background color for search matches - set fish_color_search_match --background=purple - - # Pager colors - set fish_pager_color_prefix cyan - set fish_pager_color_completion normal - set fish_pager_color_description 555 yellow - set fish_pager_color_progress cyan -end diff --git a/functions/source_script.fish b/functions/source_script.fish deleted file mode 100644 index c188908..0000000 --- a/functions/source_script.fish +++ /dev/null @@ -1,94 +0,0 @@ -# Cloned from https://github.com/fish-shell/fish-shell/issues/522 - -function source_script --description 'Source sh/csh file' - set -l ext - set -l type - - while true - switch $argv[1] - case '--sh' - set type sh - case '--csh' - set type csh - case '--bash' - set type bash - case '--ext' - set ext 1 - case '*' - break - end - set -e argv[1] - end - - if not test "$type" - for f in $argv - switch $f - case '*.sh' - set type bash - break - case '*.csh' '*.tcsh' - set type csh - break - end - end - end - - set -l exe - set -l source - - switch "$type" - case bash - set exe /bin/bash - set source . - case sh - set exe /bin/sh - set source . - case csh - set exe /bin/tcsh - set source source - case '*' - echo Unknown source type for "'$argv'" - end - - if test "$ext" - eval "exec $exe -c '$source $argv; exec fish'" - else - set -l f1 (command mktemp -t tmp.XXXXXXXXXX) - set -l f2 (command mktemp -t tmp.XXXXXXXXXX) - eval $exe -c "'env | sort > $f1; $source $argv; env | sort > $f2'" - - set -l filter "(^[^\+-]|^\+\+\+|^---|^[\+-]_|^[\+-]PIPESTATUS|^[\+-]COLUMNS)" - set -l pattern 's/[:]\{0,1\}\([^:]\+\)/"\1" /g' - - set -l IFS '=' - set -l diffopts --old-line-format '-=%L' --new-line-format '+=%L' --unchanged-line-format '' - command diff $diffopts $f1 $f2 | command grep -vE $filter | while read -l state var value - switch $state$var - case -PATH - continue - - case +PATH - eval set value (echo $value | tr : ' ') - for pt in $value - contains $pt $PATH; and continue - if not test -d $pt - echo "Unable to add '$pt' to \$PATH. Check existance." - continue - end - set -gx PATH $PATH $pt > /dev/null - end - - case '-*' - set -e $var - - case '+*' - eval set -gx $var (echo $value | command sed $pattern) - - case '*' - echo Source error! Invalid case "'$state$var'" - end - end - - command rm $f1 $f2 > /dev/null - end -end diff --git a/init.fish b/init.fish new file mode 100644 index 0000000..28017c2 --- /dev/null +++ b/init.fish @@ -0,0 +1,54 @@ +# SYNOPSIS +# Initialize Oh My Fish. +# +# ENV +# OSTYPE Operating system. +# RESET_PATH Original $PATH preseved across Oh My Fish refreshes. +# OMF_PATH Set in ~/.config/fish/config.fish +# OMF_IGNORE List of packages to ignore. +# OMF_CUSTOM Same as OMF_PATH. ~/.dotfiles by default. +# +# OVERVIEW +# + Autoload Oh My Fish packages, themes and custom path +# + For each inside {$OMF_PATH,$OMF_CUSTOM} +# + Autoload directory +# + Source .fish +# + Emit init_ event +# +# + Autoload {$OMF_PATH,$OMF_CUSTOM}/functions +# + Source {$OMF_PATH,$OMF_CUSTOM} → fish-shell/fish-shell/issues/845 +# + Source $OMF_CUSTOM/init.fish + +if set -q RESET_PATH + set PATH $RESET_PATH +else + set -gx RESET_PATH $PATH +end + +set -q OSTYPE; or set -g OSTYPE (uname) + +# Save the head of function path and autoload Oh My Fish core functions +set -l user_function_path $fish_function_path[1] +set fish_function_path[1] $OMF_PATH/lib + +set -l theme {$OMF_PATH,$OMF_CUSTOM}/themes/(cat $OMF_CONFIG/theme) +set -l paths $OMF_PATH/pkg/* +set -l custom $OMF_CUSTOM/pkg/* +set -l ignore $OMF_IGNORE + +for path in $paths + set custom $OMF_CUSTOM/(basename $path) $custom +end + +for path in $OMF_PATH/lib $OMF_PATH/lib/git $paths $theme $custom + contains -- (basename $path) $ignore; and continue + autoload $path $path/completions + source $path/(basename $path).fish + and emit init_(basename $path) $path +end + +autoload $OMF_CUSTOM/functions +autoload $user_function_path + +source {$OMF_PATH,$OMF_CUSTOM}/events.fish +source $OMF_CUSTOM/init.fish diff --git a/lib/README.md b/lib/README.md new file mode 100644 index 0000000..b2bdc83 --- /dev/null +++ b/lib/README.md @@ -0,0 +1,78 @@ +

+ + + +

+ +# Core Library + +## Basic Functions + +#### `autoload` _``_ +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`. + +```fish +autoload $mypath $mypath/completions +``` + +#### `available` _``_ + +Check if a program is available to run. Sets `$status` to `0` if the program is available. + +Use this function to check if a plugin is available before using it: + +```fish +if available battery + battery +end +``` + +#### `basename` _` ...`_ + +Wrap basename so it can handle multiple arguments. + +#### `refresh` + +Extract the root (top-most parent directory), dirname and basename from [`fish_prompt`](http://fishshell.com/docs/current/faq.html#faq-prompt). + + +#### `prompt_segments` + +Replace the running instance of fishshell with a new one causing Oh My Fish to reload as well. + + +## Git Functions +#### `git_ahead` + +Echo a character that represents whether the current repo is ahead, behind or has diverged from its upstream. + +##### Default values: + ++ ahead: `+` ++ behind: `-` ++ diverged: `±` ++ none: ` ` + +#### `git_is_repo` +Set `$status` to `0` if the current working directory belongs to a git repo. + +#### `git_branch_name` +Echo the currently checked out branch name of the current repo. + +#### `git_is_dirty` +Set `$status` to `0` if there are any changes to files already being tracked in the repo. + +#### `git_is_staged` +Set `$status` to `0` if there [staged](http://programmers.stackexchange.com/questions/119782/what-does-stage-mean-in-git) changes. + +#### `git_is_stashed` +Set `$status` to `0` if there are items in the [stash](https://git-scm.com/book/en/v1/Git-Tools-Stashing). + +#### `git_is_touched` + +Set `$status` to `0` if the repo has any changes whatsoever, including [tracked or untracked](http://stackoverflow.com/questions/9663507/what-is-tracked-files-and-untracked-files-in-the-context-of-git) files. + +#### `git_untracked` +Echo a `\n` separated list of untracked files. diff --git a/lib/autoload.fish b/lib/autoload.fish new file mode 100644 index 0000000..fdc84ee --- /dev/null +++ b/lib/autoload.fish @@ -0,0 +1,19 @@ +# SYNOPSIS +# autoload +# +# 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. + +function autoload -d "autoload a function or completion path" + for path in $argv + if test -d "$path" + set -l dest fish_function_path + if test (basename "$path") = "completions" + set dest fish_complete_path + end + contains "$path" $$dest; or set $dest "$path" $$dest + end + end +end diff --git a/lib/available.fish b/lib/available.fish new file mode 100644 index 0000000..4d44c6c --- /dev/null +++ b/lib/available.fish @@ -0,0 +1,9 @@ +# SYNOPSIS +# available [name] +# +# OVERVIEW +# Check if a program is available. + +function available -a program -d "check if a program is available." + type "$program" ^/dev/null >&2 +end diff --git a/lib/basename.fish b/lib/basename.fish new file mode 100644 index 0000000..807ebc4 --- /dev/null +++ b/lib/basename.fish @@ -0,0 +1,29 @@ +# SYNOPSIS +# basename [suffix] +# basename [-s suffix] [string...] +# +# OVERVIEW +# osx style variable arguments basename + +function basename -d "get the filename or directory part of a path" + if test (uname) = "Darwin" + command basename $argv + else + if set -q argv[1] + set -l ext "" + switch $argv[1] + case -s + if test (count $argv) -gt 2 + set ext $argv[2] + set argv $argv[3..-1] + else + echo "basename: Invalid number of arguments" + return 1 + end + end + for path in $argv + command basename "$path" "$ext" + end + end + end +end diff --git a/plugins/.gitignore b/lib/completions/.gitkeep similarity index 100% rename from plugins/.gitignore rename to lib/completions/.gitkeep diff --git a/lib/git/git_ahead.fish b/lib/git/git_ahead.fish new file mode 100644 index 0000000..7043228 --- /dev/null +++ b/lib/git/git_ahead.fish @@ -0,0 +1,15 @@ +function git_ahead -a ahead behind diverged none + git_is_repo; and begin + test -z "$ahead"; and set ahead "+" + test -z "behind"; and set behind "-" + test -z "diverged"; and set diverged "±" + test -z "none"; and set none "" + command git rev-list --left-right "@{upstream}...HEAD" ^/dev/null \ + | awk "/>/ {a += 1} / 0) nextfile} END \ + {if (a > 0 && b > 0) print \"$diverged\"; \ + else if (a > 0) print \"$ahead\"; \ + else if (b > 0) print \"$behind\"; + else printf \"$none\"}" + end +end diff --git a/lib/git/git_branch_name.fish b/lib/git/git_branch_name.fish new file mode 100644 index 0000000..557b3b9 --- /dev/null +++ b/lib/git/git_branch_name.fish @@ -0,0 +1,5 @@ +function git_branch_name -d "Get current branch name" + git_is_repo; and begin + command git symbolic-ref --short HEAD + end +end diff --git a/lib/git/git_is_dirty.fish b/lib/git/git_is_dirty.fish new file mode 100644 index 0000000..282d911 --- /dev/null +++ b/lib/git/git_is_dirty.fish @@ -0,0 +1,3 @@ +function git_is_dirty -d "Check if there are changes to tracked files" + git_is_repo; and not command git diff --no-ext-diff --quiet --exit-code +end diff --git a/lib/git/git_is_repo.fish b/lib/git/git_is_repo.fish new file mode 100644 index 0000000..df5874d --- /dev/null +++ b/lib/git/git_is_repo.fish @@ -0,0 +1,3 @@ +function git_is_repo -d "Check if directory is a repository" + test -d .git; or command git rev-parse --git-dir >/dev/null ^/dev/null +end diff --git a/lib/git/git_is_staged.fish b/lib/git/git_is_staged.fish new file mode 100644 index 0000000..e26f34a --- /dev/null +++ b/lib/git/git_is_staged.fish @@ -0,0 +1,5 @@ +function git_is_staged -d "Check if repo has staged changes" + git_is_repo; and begin + not command git diff --cached --no-ext-diff --quiet --exit-code + end +end diff --git a/lib/git/git_is_stashed.fish b/lib/git/git_is_stashed.fish new file mode 100644 index 0000000..da190ef --- /dev/null +++ b/lib/git/git_is_stashed.fish @@ -0,0 +1,5 @@ +function git_is_stashed -d "Check if repo has stashed contents" + git_is_repo; and begin + command git rev-parse --verify --quiet refs/stash >/dev/null + end +end diff --git a/lib/git/git_is_touched.fish b/lib/git/git_is_touched.fish new file mode 100644 index 0000000..172f605 --- /dev/null +++ b/lib/git/git_is_touched.fish @@ -0,0 +1,5 @@ +function git_is_touched -d "Check if repo has any changes" + git_is_repo; and begin + test -n (echo (command git status --porcelain)) + end +end diff --git a/lib/git/git_untracked.fish b/lib/git/git_untracked.fish new file mode 100644 index 0000000..fe7dcd5 --- /dev/null +++ b/lib/git/git_untracked.fish @@ -0,0 +1,5 @@ +function git_untracked -d "Print list of untracked files" + git_is_repo; and begin + command git ls-files --other --exclude-standard + end +end diff --git a/lib/prompt_segments.fish b/lib/prompt_segments.fish new file mode 100644 index 0000000..bdf10b9 --- /dev/null +++ b/lib/prompt_segments.fish @@ -0,0 +1,24 @@ +# SYNOPSIS +# set -l segs (prompt_segments) # root dir base +# +# OVERVIEW +# Extract the root (top-most parent directory), dirname and basename +# from fish_prompt + +function prompt_segments -d "extract root, dir and base from fish_prompt" + set -l root (prompt_pwd | cut -d "/" -f1) + if test -z "$root" + echo "/" + else + echo "$root" + end + set -l path (prompt_pwd | cut -d "/" -f2-) + set -l dir (dirname $path) + if test $dir != "." + echo $dir + end + set -l base (basename $path) + if test -n "$base" -a "$base" != "~" + echo $base + end +end diff --git a/lib/refresh.fish b/lib/refresh.fish new file mode 100644 index 0000000..b33d64c --- /dev/null +++ b/lib/refresh.fish @@ -0,0 +1,9 @@ +# SYNOPSIS +# refresh +# +# OVERVIEW +# Refresh (reload) the current fish session. + +function refresh -d "refresh the fish session" + exec fish < /dev/tty +end diff --git a/oh-my-fish.fish b/oh-my-fish.fish deleted file mode 100644 index 8b4a9e4..0000000 --- a/oh-my-fish.fish +++ /dev/null @@ -1,50 +0,0 @@ -# Set fish_custom to the path where your custom config files -# and plugins exist, or use the default custom instead. -if not set -q fish_custom - set -g fish_custom $fish_path/custom -end - -# Add functions defined in oh-my-fish/functions to the path. -if not contains $fish_path/functions/ $fish_function_path - set fish_function_path $fish_path/functions/ $fish_function_path -end - -if not set -q __omf_loaded - if set -q fish_plugins - set_color red - echo '$fish_plugins usage has been deprecated; please use the \'Plugin\' command.' - set_color normal - end - - if set -q fish_theme - set_color red - echo '$fish_theme usage has been deprecated; please use the \'Theme\' command.' - set_color normal - end - - if set -q fish_plugins; or set -q fish_theme - set_color yellow - echo 'See https://asciinema.org/a/20802 for info on updating config.fish.' - set_color normal - end - - set -g __omf_loaded "true" -end - -# Add imported plugins, completions and themes. Customize imported -# commands via the $fish_path/custom directory, for example create -# a directory under $fish_path/custom/themes with the same name as -# the theme and override any functions/variables there. Rinse and -# repeat for plugins. -import plugins/$fish_plugins themes/$fish_theme - -# Always load oh-my-fish plugin -import plugins/omf - -# Source all files inside custom directory. -for load in $fish_custom/*.load - . $load -end - -# Make sure to exit with $status of 1 when reloading the framework. -or true diff --git a/pkg/omf/cli/omf_destroy.fish b/pkg/omf/cli/omf_destroy.fish new file mode 100644 index 0000000..9b40e1b --- /dev/null +++ b/pkg/omf/cli/omf_destroy.fish @@ -0,0 +1,19 @@ +function omf_destroy -d "Remove Oh My Fish" + echo (omf::dim)"Removing Oh My Fish..."(omf::off) + + omf_remove_package (basename $OMF_PATH/pkg/*) >/dev/null ^&1 + + if test -e "$HOME/.config/fish/config.copy" + mv "$HOME/.config/fish/config".{copy,fish} + end + + if test (basename "$OMF_CONFIG") = "omf" + rm -rf "$OMF_CONFIG" + end + + if test "$OMF_PATH" != "$HOME" + rm -rf "$OMF_PATH" + end + + exec fish < /dev/tty +end diff --git a/pkg/omf/cli/omf_help.fish b/pkg/omf/cli/omf_help.fish new file mode 100644 index 0000000..1ff9506 --- /dev/null +++ b/pkg/omf/cli/omf_help.fish @@ -0,0 +1,20 @@ +function omf_help + echo \n"\ + "(omf::dim)"Usage"(omf::off)" + omf "(omf::em)"action"(omf::off)" [options] + + "(omf::dim)"Actions"(omf::off)" + "(omf::em)"l"(omf::off)"ist List local packages. + "(omf::em)"g"(omf::off)"et Install one or more packages. + "(omf::em)"u"(omf::off)"se List / Apply themes. + "(omf::em)"r"(omf::off)"emove Remove a theme or package. + u"(omf::em)"p"(omf::off)"date Update Oh My Fish. + "(omf::em)"n"(omf::off)"ew Create a new package from a template. + "(omf::em)"s"(omf::off)"ubmit Submit a package to the registry. + "(omf::em)"q"(omf::off)"uery Query environment variables. + "(omf::em)"h"(omf::off)"elp Display this help. + "(omf::em)"v"(omf::off)"ersion Display version. + "(omf::em)"destroy"(omf::off)" Uninstall Oh My Fish. + + For more information visit → "(omf::em)"git.io/oh-my-fish"(omf::off)\n +end diff --git a/pkg/omf/cli/omf_list_db_packages.fish b/pkg/omf/cli/omf_list_db_packages.fish new file mode 100644 index 0000000..c60905d --- /dev/null +++ b/pkg/omf/cli/omf_list_db_packages.fish @@ -0,0 +1,6 @@ +# List all packages available to install from the registry. +function omf_list_db_packages + for item in (basename $OMF_PATH/db/pkg/*) + contains $item (basename {$OMF_PATH,$OMF_CUSTOM}/pkg/*); or echo $item + end +end diff --git a/pkg/omf/cli/omf_list_installed_packages.fish b/pkg/omf/cli/omf_list_installed_packages.fish new file mode 100644 index 0000000..3bc0c1a --- /dev/null +++ b/pkg/omf/cli/omf_list_installed_packages.fish @@ -0,0 +1,6 @@ +# List all packages installed from the registry. +function omf_list_installed_packages + for item in (basename $OMF_PATH/pkg/*) + test $item = wa; or echo $item + end +end diff --git a/pkg/omf/cli/omf_list_installed_themes.fish b/pkg/omf/cli/omf_list_installed_themes.fish new file mode 100644 index 0000000..a189cb1 --- /dev/null +++ b/pkg/omf/cli/omf_list_installed_themes.fish @@ -0,0 +1,5 @@ +function omf_list_installed_themes + for item in (basename $OMF_PATH/themes/*) + test $item = default; or echo $item + end +end \ No newline at end of file diff --git a/pkg/omf/cli/omf_list_local_packages.fish b/pkg/omf/cli/omf_list_local_packages.fish new file mode 100644 index 0000000..4425bbb --- /dev/null +++ b/pkg/omf/cli/omf_list_local_packages.fish @@ -0,0 +1,6 @@ +# List all custom packages and packages installed from the registry. +function omf_list_local_packages + for item in (basename {$OMF_PATH,$OMF_CUSTOM}/pkg/*) + test $item = wa; or echo $item + end +end diff --git a/pkg/omf/cli/omf_list_themes.fish b/pkg/omf/cli/omf_list_themes.fish new file mode 100644 index 0000000..117b0ae --- /dev/null +++ b/pkg/omf/cli/omf_list_themes.fish @@ -0,0 +1,8 @@ +function omf_list_themes + set -l seen "" + for theme in (basename $OMF_PATH/db/themes/*) \ + (basename {$OMF_PATH,$OMF_CUSTOM}/themes/*) + contains $theme $seen; or echo $theme + set seen $seen $theme + end +end diff --git a/pkg/omf/cli/omf_new.fish b/pkg/omf/cli/omf_new.fish new file mode 100644 index 0000000..acbcad6 --- /dev/null +++ b/pkg/omf/cli/omf_new.fish @@ -0,0 +1,34 @@ +function omf_new -a option name + switch $option + case "p" "pkg" "pack" "packg" "package" + set option "pkg" + case "t" "th" "the" "thm" "theme" "themes" + set option "themes" + case "*" + echo (omf::err)"$option is not a valid option."(omf::off) 1^&2 + return $OMF_INVALID_ARG + end + + if not omf_util_valid_package "$name" + echo (omf::err)"$name is not a valid package/theme name"(omf::off) 1^&2 + return $OMF_INVALID_ARG + end + + if set -l dir (omf_util_mkdir "$option/$name") + cd $dir + + set -l github (git config github.user) + test -z "$github"; and set github "{{USERNAME}}" + + set -l user (git config user.name) + test -z "$user"; and set user "{{USERNAME}}" + + omf_new_from_template "$OMF_PATH/pkg/wa/templates/$option" \ + $github $user $name + + echo (omf::em)"Switched to $dir"(omf::off) + else + echo (omf::err)"\$OMF_CUSTOM and/or \$OMF_PATH undefined."(omf::off) 1^&2 + exit $OMF_UNKNOWN_ERR + end +end diff --git a/pkg/omf/cli/omf_new_from_template.fish b/pkg/omf/cli/omf_new_from_template.fish new file mode 100644 index 0000000..33f1312 --- /dev/null +++ b/pkg/omf/cli/omf_new_from_template.fish @@ -0,0 +1,27 @@ +function omf_new_from_template -a path github user name + for file in $path/* + if test -d $file + mkdir (basename $file) + pushd (basename $file) + omf_new_from_template $file $github $user $name + else + set -l target (begin + if test (basename $file) = "{{NAME}}.fish" + echo "$name.fish" + else + echo (basename "$file") + end + end) + sed "s/{{USER_NAME}}/$user/;s/{{GITHUB_USER}}/$github/;s/{{NAME}}/$name/" \ + $file > $target + echo (omf::em)" create "(omf::off)" "(begin + if test (basename $PWD) = $name + echo "" + else + echo (basename "$PWD")"/" + end + end)$target + end + end + popd >/dev/null ^&2 +end diff --git a/pkg/omf/cli/omf_package.fish b/pkg/omf/cli/omf_package.fish new file mode 100644 index 0000000..596e05e --- /dev/null +++ b/pkg/omf/cli/omf_package.fish @@ -0,0 +1,34 @@ +function omf_get_package + for search in $argv + if test -e $OMF_PATH/db/pkg/$search + set target pkg/$search + else if test -e $OMF_PATH/db/themes/$search + set target themes/$search + else + set -l pkg (basename $search) + if test -e $OMF_PATH/pkg/$pkg + echo (omf::err)"Error: $pkg already installed."(omf::off) 1^&2 + else + echo (omf::dim)"Trying to clone from URL..."(omf::err) + git clone -q $search $OMF_PATH/pkg/$pkg + and echo (omf::em)"✔ $pkg succesfully installed."(omf::off) + or echo (omf::err)"$pkg is not a valid package/theme."(omf::off) 1^&2 + end + continue + end + + if test -e $OMF_PATH/$target + echo (omf::dim)"Updating $search..."(omf::off) + pushd $OMF_PATH/$target + omf_util_sync "origin" >/dev/null ^&1 + popd + echo (omf::em)"✔ $search up to date."(omf::off) + else + echo (omf::dim)"Installing $search..."(omf::off) + git clone (cat $OMF_PATH/db/$target) $OMF_PATH/$target >/dev/null ^&1 + and echo (omf::em)"✔ $search succesfully installed."(omf::off) + or echo (omf::err)"Could not install package."(omf::off) 1^&2 + end + end + refresh +end diff --git a/pkg/omf/cli/omf_query_env.fish b/pkg/omf/cli/omf_query_env.fish new file mode 100644 index 0000000..25bdc56 --- /dev/null +++ b/pkg/omf/cli/omf_query_env.fish @@ -0,0 +1,17 @@ +function omf_query_env + function __omf_print_pretty_path -a path + printf "%s\n" $path \ + | sed "s|$HOME|"(omf::em)"~"(omf::off)"|g" \ + | sed "s|/|"(omf::em)"/"(omf::off)"|g" + end + if not set -q argv[1] + for var in (set) + echo (omf::dim)(echo $var | awk '{ printf $1"\n"; }')(omf::off) + echo (omf::em)(__omf_print_pretty_path (echo $var | awk '{$1=""; print $0}'))(omf::off) + end + else + for key in $$argv[1] + __omf_print_pretty_path $key + end + end +end diff --git a/pkg/omf/cli/omf_remove_package.fish b/pkg/omf/cli/omf_remove_package.fish new file mode 100644 index 0000000..d9346e4 --- /dev/null +++ b/pkg/omf/cli/omf_remove_package.fish @@ -0,0 +1,32 @@ +function omf_remove_package + for pkg in $argv + if not omf_util_valid_package $pkg + if test $pkg = "wa" + echo (omf::err)"You can't remove wa"(omf::off) 1^&2 + else + echo (omf::err)"$pkg is not a valid package/theme name"(omf::off) 1^&2 + end + return $OMF_INVALID_ARG + end + + if test -d $OMF_PATH/pkg/$pkg + emit uninstall_$pkg + rm -rf $OMF_PATH/pkg/$pkg + else if test -d $OMF_PATH/themes/$pkg + if test $pkg = default + echo (omf::err)"You can't remove the default theme"(omf::off) 1^&2 + return $OMF_INVALID_ARG + end + if test $pkg = (cat $OMF_CONFIG/theme) + omf_use "default" + end + rm -rf $OMF_PATH/themes/$pkg + end + if test $status -eq 0 + echo (omf::em)"$pkg succesfully removed."(omf::off) + else + echo (omf::err)"$pkg could not be found"(omf::off) 1^&2 + end + end + refresh +end \ No newline at end of file diff --git a/pkg/omf/cli/omf_submit.fish b/pkg/omf/cli/omf_submit.fish new file mode 100644 index 0000000..9bea20f --- /dev/null +++ b/pkg/omf/cli/omf_submit.fish @@ -0,0 +1,42 @@ +# SYNOPSIS +# Submit a package to the registry +# +# OPTIONS +# name Name of the package. +# [url] URL to the package repository. + +function omf_submit -a name url -d "Submit a package to the registry" + switch (dirname $name) + case pkg + case themes + case "*" + echo (omf::err)"Missing directory name: pkg/ or themes/"(omf::off) 1^&2 + return $OMF_INVALID_ARG + end + + set -l pkg (basename $name) + if not omf_util_valid_package $pkg + echo (omf::err)"$pkg is not a valid package/theme name"(omf::off) 1^&2 + return $OMF_INVALID_ARG + end + + if test -z "$url" + echo (omf::em)"URL not specified, looking for a remote origin..."(omf::off) 1^&2 + set url (git config --get remote.origin.url) + if test -z "$url" + echo (omf::em)"$pkg remote URL not found"(omf::off) 1^&2 + echo "Try: git remote add or see Docs#Submitting" 1^&2 + return $OMF_INVALID_ARG + end + else + if test -e "$OMF_PATH/db/$name" + echo (omf::err)"Error: $pkg already exists in the registry!"(omf::off) 1^&2 + return $OMF_INVALID_ARG + else + echo "$url" > $OMF_PATH/db/$name + echo (omf::em)"$pkg added to the local "(dirname $name)" registry."(omf::off) + echo "Want to contribute? Send us a PR → github.com/fish-shell/omf" + return 0 + end + end +end diff --git a/pkg/omf/cli/omf_update.fish b/pkg/omf/cli/omf_update.fish new file mode 100644 index 0000000..153e97c --- /dev/null +++ b/pkg/omf/cli/omf_update.fish @@ -0,0 +1,16 @@ +function omf_update + set -l repo "upstream" + test -z (git config --get remote.upstream.url) + and set -l repo "origin" + + if git diff-index --quiet HEAD -- >/dev/null ^&1 + git pull $repo master >/dev/null ^&1 + else + git stash >/dev/null ^&1 + if git pull --rebase $repo master >/dev/null ^&1 + git stash apply >/dev/null ^&1 + else + omf_util_sync "origin" + end + end +end \ No newline at end of file diff --git a/pkg/omf/cli/omf_use.fish b/pkg/omf/cli/omf_use.fish new file mode 100644 index 0000000..9bcbf22 --- /dev/null +++ b/pkg/omf/cli/omf_use.fish @@ -0,0 +1,18 @@ +function omf_use + if not test -e $OMF_CUSTOM/themes/$argv[1] + if not test -e $OMF_PATH/themes/$argv[1] + set -l theme $OMF_PATH/db/themes/$argv[1] + if test -e $theme + echo (omf::dim)"Downloading $argv[1] theme..."(omf::off) + git clone (cat $theme) $OMF_PATH/themes/$argv[1] >/dev/null ^&1 + and echo (omf::em)"$argv[1] theme downloaded."(omf::off) + or return $OMF_UNKNOWN_ERR + else + echo (omf::err)"$argv[1] is not a valid theme"(omf::off) 1^&2 + return $OMF_INVALID_ARG + end + end + end + echo "$argv[1]" > $OMF_CONFIG/theme + refresh +end diff --git a/pkg/omf/cli/omf_version.fish b/pkg/omf/cli/omf_version.fish new file mode 100644 index 0000000..e4c0623 --- /dev/null +++ b/pkg/omf/cli/omf_version.fish @@ -0,0 +1,3 @@ +function omf_version + echo "Oh My Fish! $OMF_VERSION" +end diff --git a/pkg/omf/completions/omf.fish b/pkg/omf/completions/omf.fish new file mode 100644 index 0000000..12d4094 --- /dev/null +++ b/pkg/omf/completions/omf.fish @@ -0,0 +1,30 @@ +# SYNOPSIS +# Completions for Oh My Fish CLI + +function __omf_is_single_opt + test (count (commandline -opc)) -le 1 +end + +function __omf_opt_is + set -l cmd (commandline -opc) + test (count $cmd) -gt 1; and contains -- $cmd[2] $argv +end + +complete --no-files -c omf -d "Oh My Fish" + +complete -c omf -n "__omf_opt_is q query" -a (printf "%s " (set | awk '{ printf $1"\n"; }')) +complete -c omf -n "__omf_opt_is r rm remove" -a (printf "%s " (omf_list_local_packages) (omf_list_installed_themes)) +complete -c omf -n "__omf_opt_is g get" -a (printf "%s " (omf_list_db_packages)) +complete -c omf -n "__omf_opt_is u use" -a (printf "%s " (omf_list_themes)) + +complete -c omf -a list -n "__omf_is_single_opt" -d "List local packages" +complete -c omf -a get -n "__omf_is_single_opt" -d "Install one or more packages" +complete -c omf -a use -n "__omf_is_single_opt" -d "List / Apply themes" +complete -c omf -a remove -n "__omf_is_single_opt" -d "Remove a theme or package" +complete -c omf -a update -n "__omf_is_single_opt" -d "Update Oh My Fish" +complete -c omf -a new -n "__omf_is_single_opt" -d "Create a new package from a template" +complete -c omf -a submit -n "__omf_is_single_opt" -d "Submit a package to the registry" +complete -c omf -a query -n "__omf_is_single_opt" -d "Query environment variables" +complete -c omf -a help -n "__omf_is_single_opt" -d "Display this help" +complete -c omf -a version -n "__omf_is_single_opt" -d "Display version" +complete -c omf -a destroy -n "__omf_is_single_opt" -d "Remove Oh My Fish" diff --git a/pkg/omf/omf.fish b/pkg/omf/omf.fish new file mode 100644 index 0000000..5c09e84 --- /dev/null +++ b/pkg/omf/omf.fish @@ -0,0 +1,126 @@ +# SYNOPSIS +# Oh My Fish CLI +# +# ENV +# OMF_VERSION Version +# OMF_CONFIG Oh My Fish configuration +# +# OVERVIEW +# Provides options to list, download and remove packages, update +# the framework, create / submit a new package, etc. + +set -g OMF_MISSING_ARG 1 +set -g OMF_UNKNOWN_OPT 2 +set -g OMF_INVALID_ARG 3 +set -g OMF_UNKNOWN_ERR 4 + +set -g OMF_VERSION "1.0.0" + +function omf::em; set_color -o yellow ; end +function omf::dim; set_color -o 888 ; end +function omf::err; set_color -o red ; end +function omf::off; set_color normal ; end + +function init -a path --on-event init_omf + autoload $path/cli $path/util +end + +function omf -d "Oh My Fish" + if test (count $argv) -eq 0 + omf_help; and return 0 + end + + switch $argv[1] + case "v" "ver" "version" + omf_version + + case "q" "query" + switch (count $argv) + case 1 + omf_query_env + case 2 + omf_query_env "$argv[2]" + case "*" + echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2 + echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" []" 1^&2 + return $OMF_INVALID_ARG + end + + case "h" "help" + omf_help + + case "l" "li" "lis" "lst" "list" + omf_list_local_packages | column + + case "g" "ge" "get" "install" + if test (count $argv) -eq 1 + omf_list_db_packages | column + else + omf_get_package $argv[2..-1] + end + + case "u" "use" + if test (count $argv) -eq 1 + set -l theme (cat $OMF_CONFIG/theme) + set -l regex "[[:<:]]($theme)[[:>:]]" + test "$OSTYPE" != "Darwin"; and set regex "\b($theme)\b" + + omf_list_themes | column | sed -E "s/$regex/"(omf::em)"\1"(omf::off)"/" + omf::off + + else if test (count $argv) -eq 2 + omf_use $argv[2] + else + echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2 + echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" []" 1^&2 + return $OMF_INVALID_ARG + end + + case "r" "rm" "remove" "uninstall" + if test (count $argv) -ne 2 + echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2 + echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" <[package|theme] name>" 1^&2 + return $OMF_INVALID_ARG + end + omf_remove_package $argv[2..-1] + + case "p" "up" "upd" "update" + pushd $OMF_PATH + echo (omf::em)"Updating Oh My Fish..."(omf::off) + if omf_update + echo (omf::em)"Oh My Fish is up to date."(omf::off) + else + echo (omf::err)"Oh My Fish failed to update."(omf::off) + echo "Please open a new issue here → "(omf::em)"git.io/omf-issues"(omf::off) + end + omf_use (cat $OMF_CONFIG/theme) + omf_get_package (omf_list_installed_packages) + popd + refresh + + case "s" "su" "sub" "submit" + switch (count $argv) + case 3 + omf_submit $argv[2] $argv[3] + case "*" + echo (omf::err)"Argument missing"(omf::off) 1^&2 + echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" "(omf::em)"pkg|themes"(omf::off)"/ " 1^&2 + return $OMF_MISSING_ARG + end + + case "n" "nw" "new" + if test (count $argv) -ne 3 + echo (omf::err)"Package type or name missing"(omf::off) 1^&2 + echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" "(omf::em)"pkg|theme"(omf::off)" " 1^&2 + return $OMF_MISSING_ARG + end + omf_new $argv[2..-1] + + case "destroy" + omf_destroy + + case "*" + echo (omf::err)"$argv[1] option not recognized"(omf::off) 1^&2 + return $OMF_UNKNOWN_OPT + end +end diff --git a/pkg/omf/templates/pkg/.travis.yml b/pkg/omf/templates/pkg/.travis.yml new file mode 100644 index 0000000..c27b118 --- /dev/null +++ b/pkg/omf/templates/pkg/.travis.yml @@ -0,0 +1,16 @@ +language: c +os: + - linux +# - osx # currently not supported +sudo: false +addons: + apt: + packages: + - tree + - fish +before_script: + - pwd; tree -h + - curl -L git.io/omf | sh +script: + - omf g {{NAME}} + - cat $OMF_PATH/pkg/{{NAME}}/test/{{NAME}}.fish diff --git a/pkg/omf/templates/pkg/LICENSE b/pkg/omf/templates/pkg/LICENSE new file mode 100644 index 0000000..0a3a99f --- /dev/null +++ b/pkg/omf/templates/pkg/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 {{USER}} + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pkg/omf/templates/pkg/README.md b/pkg/omf/templates/pkg/README.md new file mode 100644 index 0000000..aed6272 --- /dev/null +++ b/pkg/omf/templates/pkg/README.md @@ -0,0 +1,40 @@ + +
+ +> {{NAME}} for [Oh My Fish][omf-link]. + + +[![][travis-badge]][travis-link] +![][license-badge] + +## Install + + +```fish +$ omf g {{NAME}} +``` + + +## Usage + +```fish +$ {{NAME}} +``` + +# License + +[MIT][mit] © [{{USER}}][author] et [al][contributors] + + +[mit]: http://opensource.org/licenses/MIT +[author]: http://github.com/{{USER}} +[contributors]: https://github.com/{{USER}}/{{NAME}}/graphs/contributors +[omf-link]: https://www.github.com/fish-shell/omf + +[license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square +[travis-badge]: http://img.shields.io/travis/{{USER}}/{{NAME}}.svg?style=flat-square +[travis-link]: https://travis-ci.org/{{USER}}/{{NAME}} diff --git a/pkg/omf/templates/pkg/completions/{{NAME}}.fish b/pkg/omf/templates/pkg/completions/{{NAME}}.fish new file mode 100644 index 0000000..d1ad0aa --- /dev/null +++ b/pkg/omf/templates/pkg/completions/{{NAME}}.fish @@ -0,0 +1 @@ +# See → fishshell.com/docs/current/commands.html#complete diff --git a/pkg/omf/templates/pkg/test/{{NAME}}.fish b/pkg/omf/templates/pkg/test/{{NAME}}.fish new file mode 100644 index 0000000..5bdf3ab --- /dev/null +++ b/pkg/omf/templates/pkg/test/{{NAME}}.fish @@ -0,0 +1 @@ +test available {{NAME}} diff --git a/pkg/omf/templates/pkg/{{NAME}}.fish b/pkg/omf/templates/pkg/{{NAME}}.fish new file mode 100644 index 0000000..cc8bb8d --- /dev/null +++ b/pkg/omf/templates/pkg/{{NAME}}.fish @@ -0,0 +1,18 @@ +# SYNOPSIS +# {{NAME}} [options] +# +# USAGE +# Options +# + +function init -a path --on-event init_{{NAME}} + +end + +function {{NAME}} -d "My package" + +end + +function uninstall --on-event uninstall_{{NAME}} + +end diff --git a/pkg/omf/templates/themes/LICENSE b/pkg/omf/templates/themes/LICENSE new file mode 100644 index 0000000..1809744 --- /dev/null +++ b/pkg/omf/templates/themes/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 {{USER_NAME}} + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pkg/omf/templates/themes/README.md b/pkg/omf/templates/themes/README.md new file mode 100644 index 0000000..e4d5c81 --- /dev/null +++ b/pkg/omf/templates/themes/README.md @@ -0,0 +1,40 @@ + +
+ +> {{NAME}} theme for [Oh My Fish][omf-link]. + +## Install + + +```fish +$ omf u {{NAME}} +``` + +## Features + +* Lorem ipsum dolor sit amet. +* Consectetur adipisicing elit. + +## Screenshot + +

+ +

+ +# License + +[MIT][mit] © [{{USER}}][author] et [al][contributors] + + +[mit]: http://opensource.org/licenses/MIT +[author]: http://github.com/{{USER}} +[contributors]: https://github.com/{{USER}}/{{NAME}}/graphs/contributors +[omf-link]: https://www.github.com/fish-shell/omf + +[license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square +[travis-badge]: http://img.shields.io/travis/{{USER}}/{{NAME}}.svg?style=flat-square +[travis-link]: https://travis-ci.org/{{USER}}/{{NAME}} diff --git a/pkg/omf/templates/themes/fish_greeting.fish b/pkg/omf/templates/themes/fish_greeting.fish new file mode 100644 index 0000000..e572306 --- /dev/null +++ b/pkg/omf/templates/themes/fish_greeting.fish @@ -0,0 +1,12 @@ +# Set global color styles, for example: +# +# function {{NAME}}_error +# set_color -o red +# end +# +# function {{NAME}}_normal +# set_color normal +# + +function fish_greeting +end diff --git a/pkg/omf/templates/themes/fish_prompt.fish b/pkg/omf/templates/themes/fish_prompt.fish new file mode 100644 index 0000000..fab6554 --- /dev/null +++ b/pkg/omf/templates/themes/fish_prompt.fish @@ -0,0 +1,4 @@ +function fish_prompt + set -l code $status + prompt_pwd +end diff --git a/pkg/omf/templates/themes/fish_right_prompt.fish b/pkg/omf/templates/themes/fish_right_prompt.fish new file mode 100644 index 0000000..6e030d6 --- /dev/null +++ b/pkg/omf/templates/themes/fish_right_prompt.fish @@ -0,0 +1,3 @@ +function fish_right_prompt + set -l code $status +end diff --git a/pkg/omf/templates/themes/fish_title.fish b/pkg/omf/templates/themes/fish_title.fish new file mode 100644 index 0000000..a267373 --- /dev/null +++ b/pkg/omf/templates/themes/fish_title.fish @@ -0,0 +1,3 @@ +function fish_title +# Customize the title bar of the terminal window. +end diff --git a/pkg/omf/util/omf_util_fork_repo.fish b/pkg/omf/util/omf_util_fork_repo.fish new file mode 100644 index 0000000..c7b4d07 --- /dev/null +++ b/pkg/omf/util/omf_util_fork_repo.fish @@ -0,0 +1,4 @@ +function omf_util_fork_repo -a user repo + curl -u "$user" --fail --silent https://api.github.com/repos/$repo/forks \ + -d "{\"user\":\"$user\"}" >/dev/null ^&1 +end \ No newline at end of file diff --git a/pkg/omf/util/omf_util_mkdir.fish b/pkg/omf/util/omf_util_mkdir.fish new file mode 100644 index 0000000..2c0e300 --- /dev/null +++ b/pkg/omf/util/omf_util_mkdir.fish @@ -0,0 +1,10 @@ +function omf_util_mkdir -a name + set -l name "$argv[1]" + if test -d "$OMF_CUSTOM" + set name "$OMF_CUSTOM/$name" + else if test -d "$OMF_PATH" + set name "$OMF_PATH/$name" + end + mkdir -p "$name" + echo $name +end \ No newline at end of file diff --git a/pkg/omf/util/omf_util_sync.fish b/pkg/omf/util/omf_util_sync.fish new file mode 100644 index 0000000..5a4aa31 --- /dev/null +++ b/pkg/omf/util/omf_util_sync.fish @@ -0,0 +1,8 @@ +function omf_util_sync -a remote + set -l repo $remote + set -q argv[1]; and set repo $argv[1] + + git fetch origin master + git reset --hard FETCH_HEAD + git clean -df +end \ No newline at end of file diff --git a/pkg/omf/util/omf_util_valid_package.fish b/pkg/omf/util/omf_util_valid_package.fish new file mode 100644 index 0000000..2965451 --- /dev/null +++ b/pkg/omf/util/omf_util_valid_package.fish @@ -0,0 +1,14 @@ +function omf_util_valid_package -a package + test (echo "$package" | tr "[:upper:]" "[:lower:]") = "omf"; and return 10 + switch $package + case {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}\* + switch $package + case "*/*" "* *" "*&*" "*\"*" "*!*" "*&*" "*%*" "*#*" + return 10 + case "*" + return 0 + end + case "*" + return 10 + end +end diff --git a/plugins/README.md b/plugins/README.md deleted file mode 100644 index 9ab3f1d..0000000 --- a/plugins/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Plugins -* [__android-sdk__](https://github.com/oh-my-fish/plugin-android-sdk) – [Android SDK](http://developer.android.com/sdk/index.html) integration. -* [__archlinux__](https://github.com/oh-my-fish/plugin-archlinux) – Provides a number of plugins to make using Arch Linux easier. -* [__better-alias__](https://github.com/oh-my-fish/plugin-balias) - Provide alias with auto completion. -* [__brew__](https://github.com/oh-my-fish/plugin-brew) – [Homebrew](http://brew.sh/) integration. -* [__bundler__](https://github.com/oh-my-fish/plugin-bundler) – Use Ruby's [Bundler](http://bundler.io/) automatically for some commands. -* [__ccache__](https://github.com/oh-my-fish/plugin-ccache) – Enable [ccache](http://ccache.samba.org/) to speed up compilation. -* [__django__](https://github.com/oh-my-fish/plugin-django) – Helper for Django Unit tests. Cleans the cached modules as well. -* [__ec2__](https://github.com/oh-my-fish/plugin-ec2) – Exports env variables for Amazon's EC2 management. -* [__emacs__](https://github.com/oh-my-fish/plugin-emacs) – Wrapper for [daemon](http://www.emacswiki.org/emacs/EmacsAsDaemon) functionality of [Emacs](https://www.gnu.org/software/emacs/). -* [__emoji-clock__](https://github.com/oh-my-fish/plugin-emoji-clock) – The current time with half hour accuracy as an emoji symbol. -* [__extract__](https://github.com/oh-my-fish/plugin-extract) – Plugin to expand or extract bundled & compressed files. -* [__fish-spec__](https://github.com/oh-my-fish/plugin-fish-spec) - Unit testing as simple as fish. See the [README](fish-spec/README.markdown) for usage instructions. -* [__foreign-env__](https://github.com/oh-my-fish/plugin-foreign-env) – Run foreign applications (like nvm) and capture environment variable changes. -* [__fry__](https://github.com/oh-my-fish/plugin-fry) – Starts [fry](https://github.com/terlar/fry), a simple Ruby version manager for fish. -* [__gem__](https://github.com/oh-my-fish/plugin-gem) – Ruby gem integration. -* [__getopts__](https://github.com/oh-my-fish/plugin-getopts) [(issues)](https://github.com/bucaran/getopts) - A [Unix compliant](http://pubs.opengroup.org/onlinepubs/7908799/xbd/utilconv.html) implementation of [`getopts`](http://en.wikipedia.org/wiki/Getopts) for fish. -* [__gi__](https://github.com/oh-my-fish/plugin-gi) – [gitignore.io](http://gitignore.io) CLI for fish. -* [__git-flow__](https://github.com/oh-my-fish/plugin-git-flow) – [git-flow](https://github.com/nvie/gitflow) Completion support for git-flow. -* [__grc__](https://github.com/oh-my-fish/plugin-grc) – [grc](http://kassiopeia.juls.savba.sk/~garabik/software/grc.html) Colourizer for some commands. -* [__jump__](https://github.com/oh-my-fish/plugin-jump) – A port of [Jeroen Janssens’ “jump” utility](http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html). -* [__local-config__](https://github.com/oh-my-fish/plugin-local-config) – Support per-user, per-host and per-platform custom config files. -* [__localhost__](https://github.com/oh-my-fish/plugin-localhost) – Opens `http://localhost:3000` (and other ports) in the default browser. -* [__mc__](https://github.com/oh-my-fish/plugin-mc) – Plugin to start mc with a shell compliant (Bash). -* [__msg__](https://github.com/oh-my-fish/plugin-msg) - A technicolor message printer. A colorful alternative to echo. -* [__ndenv__](https://github.com/oh-my-fish/plugin-ndenv) – Helpers for [another node.js version manager](https://github.com/riywo/ndenv). -* [__node__](https://github.com/oh-my-fish/plugin-node) – Adds locally installed NodeJS `npm` binary executable modules to the path. -* [__pbcopy__](https://github.com/oh-my-fish/plugin-pbcopy) – OSX's pbcopy and pbpaste for Linux. -* [__percol__](https://github.com/oh-my-fish/plugin-percol) – Browse your fish history with [percol](https://github.com/mooz/percol). -* [__peco__](https://github.com/oh-my-fish/plugin-peco) – Browse your fish history with [peco](https://github.com/peco/peco). -* [__osx__](https://github.com/oh-my-fish/plugin-osx) - Integration with Finder and iTunes. -* [__php__](https://github.com/oh-my-fish/plugin-php) – Manage phphttp server. -* [__plenv__](https://github.com/oh-my-fish/plugin-plenv) – [plenv](https://github.com/tokuhirom/plenv) Perl binary manager integration. -* [__pyenv__](https://github.com/oh-my-fish/plugin-pyenv) – [Simple Python Version Management](https://github.com/yyuu/pyenv) integration. -* [__python__](https://github.com/oh-my-fish/plugin-python) – Set of shortcuts to Python based utilities (pybeatifyjson – clean JSON files, pyclean – remove old `.pyc`, pyhttp & pysmtp – simple HTTP & SMTP servers) -* [__rails__](https://github.com/oh-my-fish/plugin-rails) – Alias for executing database migrations. -* [__rbenv__](https://github.com/oh-my-fish/plugin-rbenv) – [rbenv](https://github.com/sstephenson/rbenv) Ruby environment/version manager. -* [__replace__](https://github.com/oh-my-fish/plugin-replace) – A port of [replace](https://github.com/thoughtbot/dotfiles/blob/master/bin/replace). -* [__rvm__](https://github.com/oh-my-fish/plugin-rvm) – [RVM](http://rvm.io) Ruby version manager. -* [__ssh__](https://github.com/oh-my-fish/plugin-ssh) – ssh conservative $TERM value helper. -* [__sublime__](https://github.com/oh-my-fish/plugin-sublime) – Creates `subl` command line shortcut to launch [Sublime Text editor](http://sublimetext.com/). -* [__tab__](https://github.com/oh-my-fish/plugin-tab) – Open the current directory (or any other directory) in a new tab. -* [__theme__](https://github.com/oh-my-fish/plugin-theme) – Quick theme switcher. -* [__tiny__](https://github.com/oh-my-fish/plugin-tiny) - tap into github's git.io URL shortener. -* [__title__](https://github.com/oh-my-fish/plugin-title) – Change your terminal title! -* [__tmux__](https://github.com/oh-my-fish/plugin-tmux) – Plugin to start tmux with support for 256 colours. -* [__vi-mode__](https://github.com/oh-my-fish/plugin-vi-mode) – Basic vi key bindings emulation for fish. -* [__xdg__](https://github.com/oh-my-fish/plugin-xdg) – Setup [xdg](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) environment on Linux. -* [__z__](https://github.com/oh-my-fish/plugin-z) – Integration with [z](https://github.com/rupa/z) (autojump alternative). diff --git a/plugins/fish-spec/README.md b/plugins/fish-spec/README.md deleted file mode 100644 index 545f4f5..0000000 --- a/plugins/fish-spec/README.md +++ /dev/null @@ -1,109 +0,0 @@ -# fish-spec -> Unit testing as simple as fish. - -The following guide describes how to use the `fish-spec` plugin bundled with Oh-My-Fish. - -## Install -Before you can use `fish-spec`, you need to install [Oh-My-Fish](https://github.com/oh-my-fish/oh-my-fish). - -## Usage -Import the library into your fish file via [import](https://github.com/oh-my-fish/oh-my-fish/blob/master/functions/import.fish). - -Inside your project's directory create a new `spec` folder and add all your _spec_ files inside. _Spec_ files are regular fish files that shall look like `*.spec.fish` and contain your tests. - -You can have multiple `spec.fish` files to organize your tests in a per module basis, or you can squash everything into a single file and use describe blocks to separate groups of tests. - -A `spec.file` usually looks like this: - -```fish -import plugins/fish-spec -import plugins/the-library - -# Use -d to enter a friendly description (optional) -function describe_library -d "the grand library" - - function before_all - # Optional. Runs only once before all the tests. - end - - function after_all - # Optional. Runs only once after all the tests. - end - - function before_each - # Optional. Runs once before each test. - end - - function after_each - # Optional. Runs once after each test. - end - - function it_does_this - # ... - expect $what_I_got --to-equal $what_I_wanted - end - - function it_does_that - # ... - expect $a_list --to-contain-all $expected_items - end - - # ... -end - -# Run tests when this file is sourced. -spec.run $argv -``` - -## API - -As of now, there is only one method you should be aware of, [expect](https://github.com/oh-my-fish/oh-my-fish/blob/master/plugins/fish-spec/expect.fish): - -> Assert a list of expected values match an actual value/s. - -Under the hood, _expect_ checks an _actual_ value, usually a relevant result from your test unit, is equal to, not equal to, etc., to an _expected_ value, as determined by your test. Below are the list of conditions available to use with `expect`: - -* __--to-equal__ -`` value equals the `` value. For example: -```fish -expect $my_value --to-equal 5 -``` - -* __--to-not-equal__ -`` value does not equal the `` value -```fish -expect $my_string --to-not-equal "oh-the-fish" -``` - -* __--to-contain-all__ all `` values exist in the `` list -```fish -expect $elements --to-contain-all "earth" "fire" "water" "air" -``` - -* __--to-not-contain-all__ no `` values exist in `` list -```fish -expect $our_planets --to-not-contain-all "golomo" "borg prime" "rigel" "terra" -``` - -* __--to-be-true__ the exit status should be _truthy_ -```fish -__my_plugin_improve_workflow -expect $status --to-be-true -``` - -* __--to-be-false__ the exit status should be _falsy_ -```fish -__my_plugin_erase_drive -expect $status --to-be-false -``` - -## FAQ -1. __How to use `fish-spec` without Oh-My-Fish?__ -`fish-spec` is currently only available bundled with Oh-My-Fish. As the library matures and grows, however, a future guide describing how to export `fish-spec` may be written. - -## Authors -+ [Bruno Pinto](https://github.com/bpinto) -+ [Jorge Bucaran](https://bucaran.me) - -## License -[MIT](http://opensource.org/licenses/MIT) diff --git a/plugins/fish-spec/eval.fish b/plugins/fish-spec/eval.fish deleted file mode 100644 index 3dd9c78..0000000 --- a/plugins/fish-spec/eval.fish +++ /dev/null @@ -1,60 +0,0 @@ -function eval -S -d "Evaluate parameters as a command" - # keep a copy of the previous $status and use restore_status - # to preserve the status in case the block that is evaluated - # does not modify the status itself. - set -l status_copy $status - function -S restore_status - return $status_copy - end - - if not set -q argv[2] - # like most builtins, we only check for -h/--help - # if we only have a single argument - switch "$argv[1]" - case -h --help - __fish_print_help eval - return 0 - end - end - - # If we are in an interactive shell, eval should enable full - # job control since it should behave like the real code was - # executed. If we don't do this, commands that expect to be - # used interactively, like less, wont work using eval. - - set -l mode - if status --is-interactive-job-control - set mode interactive - else - if status --is-full-job-control - set mode full - else - set mode none - end - end - if status --is-interactive - status --job-control full - end - - # rfish: To eval 'foo', we construct a block "begin ; foo; end <&3 3<&-" - # The 'eval2_inner' is a param to 'begin' itself; I believe it does nothing. - # Note the redirections are also within the quotes. - # - # We then pipe this to 'source 3<&0' which dup2's 3 to stdin. - # - # You might expect that the dup2(3, stdin) should overwrite stdin, - # and therefore prevent 'source' from reading the piped-in block. This doesn't - # happen because when you pipe to a builtin, we don't overwrite stdin with the - # read end of the block; instead we set a separate fd in a variable 'builtin_stdin', - # which is what it reads from. So builtins are magic in that, in pipes, their stdin - # is not fd 0. - - restore_status - echo "begin; $argv "\n" ;end eval2_inner <&3 3<&-" | source 3<&0 - set -l res $status - - status --job-control $mode - functions -e restore_status - - return $res -end diff --git a/plugins/fish-spec/expect.fish b/plugins/fish-spec/expect.fish deleted file mode 100644 index d356862..0000000 --- a/plugins/fish-spec/expect.fish +++ /dev/null @@ -1,94 +0,0 @@ -# NAME -# expect - assert a list of expected values match an actual value -# -# SYNOPSIS -# expect - -# OPTIONS -# ... -# -# --to-equal value equals value -# --to-not-equal value does not equals value -# -# --to-contain-all all values exist in list -# --to-not-contain-all all values does not exist in list -# --to-be-true exit status should be truthy -# --to-be-false exit status should be falsy -# ... -# -# EXAMPLE -# import plugins/fish-spec -# -# function describe_my_test -# function it_does_my_task -# set -l result (my_task $data) -# expect $result --to-equal 0 -# end -# end -# spec.run -# -# AUTHORS -# Bruno Pinto <@pfbruno> -# Jorge Bucaran <@bucaran> -#/ -function expect - set -l result 0 - # Parse expected / actual lists - set -l actual "" - set -l expected "" - set -l condition "" - - for index in (seq (count $argv)) - switch $argv[$index] - # --condition found, split expected/actual lists - case --\* - set expected $argv[1..(math $index-1)] - set condition $argv[$index] - # No comparison required e.g. --to-be-true - if [ $index -lt (count $argv) ] - set actual $argv[(math $index+1)..-1] - end - break - end - end - - # Test conditions - switch $condition - case --to-be-false - eval "$expected" - test $status -ne 0 - case --to-be-true - eval "$expected" - test $status -eq 0 - case --to-contain-all - set result 0 - for item in $actual - contains -- "$item" $expected - or set result $status - end - test $result -eq 0 - case --to-not-contain-all - set result 0 - for item in $actual - contains -- "$item" $expected - or set result $status - end - test $result -ne 0 - case --to-equal - test "$expected" = "$actual" - case --to-not-equal - test "$expected" != "$actual" - case \* - test true = false - end - - set result $status - if [ $result -eq 0 ] - # Return a non-empty string to indicate success. - set -g _spec_current_test_ouput (printf "$result") - else - # Return error information separated by \t and tested condition. - set -g _spec_current_test_ouput (printf "%s\n" $expected \t $condition $actual) - end - return $result -end diff --git a/plugins/fish-spec/list.erase.fish b/plugins/fish-spec/list.erase.fish deleted file mode 100644 index 729d672..0000000 --- a/plugins/fish-spec/list.erase.fish +++ /dev/null @@ -1,41 +0,0 @@ -# NAME -# list.erase - erase any items from one or more lists -# -# SYNOPSIS -# [...] [--from] -# [...] --from [...] -# -# DESCRIPTION -# Erase any number of items from any number of lists. If more than one -# list is specified it must be separated from the items with --from. -# -# NOTES -# While items are basically any valid sequence of symbols, lists refer -# to any global variable or local variable in the scope of the calling -# function by name. -# -# AUTHORS -# Jorge Bucaran <@bucaran> -#/ -function -S list.erase - # Assume no items were erased. - set -l result 1 - # At least one list should be at the last index. - set -l items $argv[1..-2] - set -l lists $argv[-1] - if set -l index (contains -i -- --from $argv) - # --from - set items $argv[1..(math $index-1)] - set lists $argv[(math $index+1)..-1] - end - for item in $items - for list in $lists - if set -l index (contains -i -- $item $$list) - set -e $list[1][$index] - # Function succeeds if at least an item is erased. - set result 0 - end - end - end - return $result -end diff --git a/plugins/fish-spec/spec.eval.fish b/plugins/fish-spec/spec.eval.fish deleted file mode 100644 index 385366d..0000000 --- a/plugins/fish-spec/spec.eval.fish +++ /dev/null @@ -1,34 +0,0 @@ -# NAME -# spec.eval - eval a test function -# -# SYNOPSIS -# spec.eval [OPTIONS...] -# -# OPTIONS -# See spec.report -# -# AUTHORS -# Bruno Pinto <@pfbruno> -# Jorge Bucaran <@bucaran> -#/ -import plugins/msg - -function spec.eval - set -l result $status - set -l test $argv[1] - set -e argv[1] - - if functions -q $test - # Erase previous test output - set -e _spec_current_test_ouput - - # Run the test yielding control to the user defined spec. - eval $test - set result $status - - # Display test results. - spec.view $test $result $argv -- $_spec_current_test_ouput - end - - return $result -end diff --git a/plugins/fish-spec/spec.functions.fish b/plugins/fish-spec/spec.functions.fish deleted file mode 100644 index 90a12c8..0000000 --- a/plugins/fish-spec/spec.functions.fish +++ /dev/null @@ -1,106 +0,0 @@ -# NAME -# spec.functions - return functions in the global scope that match ^key -# -# SYNOPSIS -# spec.functions [OPTIONS] -# -# OPTIONS -# -b --backup -# Create new backup functions for all functions by with a -# -# -r --restore -# Create new functions without . -# -# -q --quiet -# Quiet mode. No output. Return 1 if no functions are found. -# -# -e --erase -# Erase the matched functions. -# -# EXAMPLES -# 1) spec.functions "describe_" -# 2) spec.functions -q "before_" -# -# 3) spec.functions -be "describe_" "it_" -- bak_ -# Backup all describe_* and it_* functions to bak_describe_* and -# bak_it_* and erases the original describe_* and it_* -# -# 4) spec.functions -r bak_ -# Find all bak_* functions and copies them without the prefix bak_. -# -# AUTHORS -# Jorge Bucaran <@bucaran> -#/ -function spec.functions - # Parse custom options - set -l backup - set -l prefix - set -l restore - set -l quiet - set -l erase - set -l keys - for index in (seq (count $argv)) - switch $argv[$index] - case -q --quiet - set quiet -q - # N-switch-fallthrough pattern in fish. - case -b\* -r\* -e\* - switch $argv[$index] - case -b -be -eb --backup - set backup -b - if set -l separator (contains -i -- "--" $argv[$index..-1]) - set prefix $argv[(math $separator + 1)] - else - set prefix $argv[(math $index + 2)] - end - end - switch $argv[$index] - case -e -be -eb --erase -re -er - set erase -e - end - switch $argv[$index] - case -r -re -er --restore - # Using restore takes only one argument, - set restore -r - set prefix $argv[(math $index + 1)] - end - case \* - set keys $keys $argv[$index] - end - end - - # Skip empty strings to avoid fetching all global functions. - if [ -n "$keys" ] - if [ -n "$restore" -a -n "$prefix" ] - set keys $prefix - end - - set -l list - for key in $keys - set list $list (functions -n | grep \^"$key") - end - - if [ -n "$list" ] - if [ -n "$erase" -o -n "$prefix" ] - - for item in $list - if [ -n "$backup" -a "$prefix" ] - functions -c $item $prefix$item - end - if [ -n "$restore" -a "$prefix" ] - # Cut prefix from function and create a new copy. - functions -c $item (echo $item | \ - cut -c (echo $prefix | awk '{ print length + 1 }')-) - end - if [ -n "$erase" ] - functions -e $item - end - end - - else if [ -z "$quiet" ] - printf "%s\n" $list - end - return 0 - end - end -end diff --git a/plugins/fish-spec/spec.run.fish b/plugins/fish-spec/spec.run.fish deleted file mode 100644 index e9e8de9..0000000 --- a/plugins/fish-spec/spec.run.fish +++ /dev/null @@ -1,93 +0,0 @@ -# NAME -# spec.run - run a suite of tests -# -# SYNOPSIS -# spec.run [OPTIONS] -# -# OPTIONS -# -v --verbose -# Print full test output. -# -# DESCRIPTION -# In order to run tests create the test file, import plugins/spec at -# before adding any of the functions described above and call spec.run. -# -# FUNCTIONS -# function before_all Run before any tests are run. -# function before_each Run before each test. -# function describe_* Use to organize different specs. -# function it_* Use to test your library/plugin. -# function after_each Run after each test. -# function after_all Run after all tests are finished. -# -# NOTES -# After each test is evaluated, the function is erased from the scope by -# spec.eval to guarantee that subsequent describe blocks will not end up -# calling the previous describe's batch of tests. -# -# The fish-spec library is no different from other Oh-My-Fish plugins. -# Use `import plugins/fish-spec` at the top of your spec file and call -# -# spec.run $argv -# -# After your suite of tests. -# -# EXAMPLES -# import plugins/fish-spec -# function describe_erase -# function before_each -# set -g nums 1 2 3 -# end -# function it_erases_one_item -d "It should erase an item from a list." -# erase 1 --from nums -# expect $nums --to-not-contain 1 -# end -# end -# spec.run --verbose -# -# AUTHORS -# Bruno Pinto <@pfbruno> -# Jorge Bucaran <@bucaran> -#/ -function spec.run - set -l result 0 - set -l tests "" - set -l describes (spec.functions describe_) - - # Load this suite unique set of tests. - for describe in $describes - spec.eval $describe --header $argv - spec.eval before_all $argv - - set tests (spec.functions it_) - set -l failed 0 - - for test in $tests - spec.eval before_each $argv - - if not spec.eval $test --tab 1 $argv - set result 1 # Flunk! - set failed (math 1+$failed) - end - - spec.eval after_each $argv - end - spec.eval after_all $argv - - if contains -- $argv[1] -v --verbose - spec.view --report (count $tests) $failed - end - - # Clean up methods after all tests are finished. - spec.functions -e it_ before_ after_ - end - - if [ -z "$describes" -o -z "$tests" ] - echo "No tests found." - return 1 - end - - spec.functions -e describe_ - - return $result -end diff --git a/plugins/fish-spec/spec.view.fish b/plugins/fish-spec/spec.view.fish deleted file mode 100644 index dc2677f..0000000 --- a/plugins/fish-spec/spec.view.fish +++ /dev/null @@ -1,118 +0,0 @@ -# NAME -# spec.view - print test output -# -# SYNOPSIS -# spec.view [OPTIONS] -- -# spec.view -r --report -# -# OPTIONS -# -r --report -# Print a passed / failed diagnostics report. Verbose assumed. -# -# -v --verbose -# Print test full output. -# -# -h --header -# -# -t --tab -# Use to specify the tab indentation of nested tests inside suites. -# -# AUTHORS -# Jorge Bucaran <@bucaran> -#/ -function spec.view - # Redefine these colors to customize the report. - set -l _color_default @white - set -l _color_pass @springgreen - set -l _color_info @lgray - set -l _color_fail @red - set -l _color_fail_info @black:yellow - set -l _color_dump 555 - - set -l verbose "" - if contains -- $argv[1] -r --report - set -l total_tests $argv[2] - set -l failed_tests $argv[3] - - set -l passed_tests (math $total_tests - $failed_tests) - - test $passed_tests -gt 0 - and msg \n $_color_pass "$passed_tests passing" - - test $failed_tests -gt 0 - and msg $_color_fail "$failed_tests failing" - echo # Blank link - - return 0 - end - - # Use test name or -d description field if available. - set -l info (type $argv[1] \ - | head -n 2 \ - | tail -n 1 \ - | cut -d" " -f4- \ - | sed "s/^\'//g" \ - | sed "s/\'\$//g") - - if [ -z "$info" ] - set info (echo $argv[1] | tr "_" " ") - end - - set -l result $argv[2] - set -l output - - # Parse format options. - set -l tab 1 - set -l header "" - if set -q argv[3] - for index in (seq 3 (count $argv)) - switch "$argv[$index]" - case -v --verbose - set verbose -v - case -h --header - set header $info - case -t --tab - set tab $argv[(math $index + 1)] - case -- - if [ $index -lt (count $argv) ] - set output $argv[(math $index + 1)..-1] - end - break - end - end - end - - # Print a header if available. - if [ -n "$header" -a "$verbose" ] - msg $_color_default _$header\_ - end - - # Process test functions with output. Typically it_ tests using `expect`. - if [ -n "$output" ] - set tab (printf " %.0s" (seq $tab)) - # Process succesful tests. - if [ $result -eq 0 ] - if [ -n "$verbose" ] - msg $tab $_color_pass ✔ $_color_info $info - else - echo -n (set_color 00FF7F). - end - else - msg $tab $_color_fail ✖ $_color_fail_info $info - - # Error dump parser, split output by \t. - set -l index (contains -i -- \t $output) - - # Transform condition string to TitleCase - set condition (echo $output[(math $index+1)] \ - | tr "-" " " \ - | cut -c 3- \ - | awk '{for(j=1;j<=NF;j++){ $j=toupper(substr($j,1,1)) substr($j,2) }}1') - - msg $tab __Expected__ - printf (set_color $_color_dump)"$tab %s\n" $output[1..(math $index-1)] - msg $tab $condition - printf (set_color $_color_dump)"$tab %s\n" $output[(math $index+2)..-1] - end - end -end diff --git a/plugins/fish-spec/spec/expect.spec.fish b/plugins/fish-spec/spec/expect.spec.fish deleted file mode 100644 index 8fa0728..0000000 --- a/plugins/fish-spec/spec/expect.spec.fish +++ /dev/null @@ -1,14 +0,0 @@ -import plugins/fish-spec - -function describe_expect - function before_each - set -e result - end - - function it_is_false_when_comparison_does_not_exist - echo (expect true --invalid-comparison; set result $status) >/dev/null - expect $result --to-equal 1 - end -end - -spec.run $argv diff --git a/plugins/fish-spec/spec/expect.to_be_false.spec.fish b/plugins/fish-spec/spec/expect.to_be_false.spec.fish deleted file mode 100644 index b3d07c7..0000000 --- a/plugins/fish-spec/spec/expect.to_be_false.spec.fish +++ /dev/null @@ -1,29 +0,0 @@ -import plugins/fish-spec - -function describe_expect_to_be_false - function it_returns_1_when_evaluated_value_is_0 - expect true --to-be-false - - expect $status --to-equal 1 - end - - function it_returns_0_when_evaluated_value_is_1 - expect false --to-be-false - - expect $status --to-equal 0 - end - - function it_returns_1_when_evaluated_function_returns_0 - expect "eval true" --to-be-false - - expect $status --to-equal 1 - end - - function it_returns_0_when_evaluated_function_returns_1 - expect "eval false" --to-be-false - - expect $status --to-equal 0 - end -end - -spec.run $argv diff --git a/plugins/fish-spec/spec/expect.to_be_true.spec.fish b/plugins/fish-spec/spec/expect.to_be_true.spec.fish deleted file mode 100644 index 3d2b7c9..0000000 --- a/plugins/fish-spec/spec/expect.to_be_true.spec.fish +++ /dev/null @@ -1,29 +0,0 @@ -import plugins/fish-spec - -function describe_expect_to_be_true - function it_returns_0_when_evaluated_value_returns_0 - expect true --to-be-true - - expect $status --to-equal 0 - end - - function it_returns_1_when_evaluated_value_returns_1 - expect false --to-be-true - - expect $status --to-equal 1 - end - - function it_returns_0_when_evaluated_function_returns_0 - expect "eval true" --to-be-true - - expect $status --to-equal 0 - end - - function it_returns_1_when_evaluated_function_returns_1 - expect "eval false" --to-be-true - - expect $status --to-equal 1 - end -end - -spec.run $argv diff --git a/plugins/fish-spec/spec/expect.to_contain_all.spec.fish b/plugins/fish-spec/spec/expect.to_contain_all.spec.fish deleted file mode 100644 index db69874..0000000 --- a/plugins/fish-spec/spec/expect.to_contain_all.spec.fish +++ /dev/null @@ -1,53 +0,0 @@ -import plugins/fish-spec - -function describe_expect_to_contain_all - function it_returns_0_when_lists_are_the_same - expect 1 2 --to-contain-all 1 2 - - expect $status --to-equal 0 - end - - function it_returns_1_when_lists_are_different - expect 1 2 --to-contain-all 8 9 - - expect $status --to-equal 1 - end - - function it_returns_0_when_lists_have_the_same_item_but_in_different_order - expect 1 2 --to-contain-all 2 1 - - expect $status --to-equal 0 - end - - function it_returns_0_when_expected_list_contains_the_item - expect 1 2 --to-contain-all 1 - - expect $status --to-equal 0 - end - - function it_returns_1_when_expected_list_does_not_contain_the_item - expect 1 2 --to-contain-all 9 - - expect $status --to-equal 1 - end - - function it_returns_0_when_expected_list_contains_all_items - expect 1 2 3 --to-contain-all 1 2 - - expect $status --to-equal 0 - end - - function it_returns_1_when_expected_list_does_not_contain_all_items - expect 1 2 3 --to-contain-all 1 2 9 - - expect $status --to-equal 1 - end - - function it_returns_1_when_expected_list_contains_less_items - expect 1 2 --to-contain-all 1 2 9 - - expect $status --to-equal 1 - end -end - -spec.run $argv diff --git a/plugins/fish-spec/spec/expect.to_equal.spec.fish b/plugins/fish-spec/spec/expect.to_equal.spec.fish deleted file mode 100644 index 178b4e4..0000000 --- a/plugins/fish-spec/spec/expect.to_equal.spec.fish +++ /dev/null @@ -1,29 +0,0 @@ -import plugins/fish-spec - -function describe_expect_to_equal - function it_returns_0_when_compared_values_are_the_same - expect 'equal' --to-equal 'equal' - - expect $status --to-equal 0 - end - - function it_returns_1_when_compared_values_are_different - expect 'equal' --to-equal 'different' - - expect $status --to-equal 1 - end - - function it_returns_0_when_list_items_are_in_the_same_order - expect 1 2 --to-equal 1 2 - - expect $status --to-equal 0 - end - - function it_returns_1_when_list_items_are_in_different_order - expect 1 2 --to-equal 2 1 - - expect $status --to-equal 1 - end -end - -spec.run $argv diff --git a/plugins/fish-spec/spec/expect.to_not_contain_all.spec.fish b/plugins/fish-spec/spec/expect.to_not_contain_all.spec.fish deleted file mode 100644 index 6c7bc54..0000000 --- a/plugins/fish-spec/spec/expect.to_not_contain_all.spec.fish +++ /dev/null @@ -1,53 +0,0 @@ -import plugins/fish-spec - -function describe_expect_to_not_contain_all - function it_is_false_when_lists_are_the_same - expect 1 2 --to-not-contain-all 1 2 - - expect $status --to-equal 1 - end - - function it_is_true_when_lists_are_different - expect 1 2 --to-not-contain-all 8 9 - - expect $status --to-equal 0 - end - - function it_is_false_when_lists_have_the_same_items_but_in_different_order - expect 1 2 --to-not-contain-all 2 1 - - expect $status --to-equal 1 - end - - function it_is_false_when_expected_list_contains_an_item - expect 1 2 --to-not-contain-all 1 - - expect $status --to-equal 1 - end - - function it_is_true_when_expected_list_does_not_contain_an_item - expect 1 2 --to-not-contain-all 9 - - expect $status --to-equal 0 - end - - function it_is_false_when_expected_list_contains_all_items - expect 1 2 3 --to-not-contain-all 1 2 - - expect $status --to-equal 1 - end - - function it_is_true_when_expected_array_does_not_contain_any_items - expect 1 2 3 --to-not-contain-all 8 9 - - expect $status --to-equal 0 - end - - function it_is_true_when_expected_array_contains_less_items - expect 1 2 --to-not-contain-all 1 2 9 - - expect $status --to-equal 0 - end -end - -spec.run $argv diff --git a/plugins/fish-spec/spec/list.erase.spec.fish b/plugins/fish-spec/spec/list.erase.spec.fish deleted file mode 100644 index 777ff8e..0000000 --- a/plugins/fish-spec/spec/list.erase.spec.fish +++ /dev/null @@ -1,71 +0,0 @@ -import plugins/fish-spec - -function describe_list.erase - function before_each - set -g nums_until_10 1 2 3 4 5 6 7 8 9 10 - set -g odds_until_10 1 3 5 7 9 - end - - function it_erases_one_element - list.erase 1 nums_until_10 - expect $nums_until_10 --to-not-contain-all 1 - end - - function it_erases_one_element_without_from_option - list.erase 1 --from nums_until_10 - expect $nums_until_10 --to-not-contain-all 1 - end - - function it_erases_one_element_from_multiple_lists - list.erase 1 --from nums_until_10 odds_until_10 - expect $nums_until_10 --to-not-contain-all 1 - and expect $odds_until_10 --to-not-contain-all 1 - end - - function it_erases_one_element_from_multiple_lists_when_only_one_has_the_element - list.erase 2 --from nums_until_10 odds_until_10 - expect $nums_until_10 --to-not-contain-all 2 - end - - function it_erases_multiple_elements - list.erase 1 2 nums_until_10 - expect $nums_until_10 --to-not-contain-all 1 - and expect $nums_until_10 --to-not-contain-all 2 - end - - function it_erases_multiple_elements_with_from_syntax - list.erase 1 2 --from nums_until_10 - expect $nums_until_10 --to-not-contain-all 1 - and expect $nums_until_10 --to-not-contain-all 2 - end - - function it_erases_multiple_elements_from_multiple_lists - list.erase 1 2 --from nums_until_10 odds_until_10 - expect $nums_until_10 --to-not-contain-all 1 - and expect $nums_until_10 --to-not-contain-all 2 - and expect $odds_until_10 --to-not-contain-all 1 - end - - function it_returns_0_if_any_items_are_erased - list.erase 10 --from nums_until_10 - expect $status --to-equal 0 - end - - function it_returns_1_if_no_items_are_erased - list.erase 100 200 300 --from nums_until_10 - expect $status --to-equal 1 - end - - function it_returns_1_if_no_items_are_erased_from_any_lists - list.erase 100 200 300 --from nums_until_10 odds_until_10 - expect $status --to-equal 1 - end - - function it_returns_0_if_items_are_erased_from_some_but_not_all_lists - list.erase 1 2 3 --from nums_until_10 odds_until_10 - expect $status --to-equal 0 - end - -end - -spec.run $argv diff --git a/plugins/fish-spec/spec/spec.spec.fish b/plugins/fish-spec/spec/spec.spec.fish deleted file mode 100644 index 50f31c6..0000000 --- a/plugins/fish-spec/spec/spec.spec.fish +++ /dev/null @@ -1,155 +0,0 @@ -import plugins/fish-spec - -function describe_fish-spec - function it_has_an_output_if_suite_is_blank - set -l suite " - import plugins/fish-spec - spec.run - " - expect (run_nested_suite $suite) --to-equal "No tests found." - end - - function it_has_an_output_if_there_are_no_tests - set -l suite " - import plugins/fish-spec - - function describe_blank_suite - end - - spec.run - " - expect (run_nested_suite $suite) --to-equal "No tests found." - end - - function it_runs_all_describe_blocks - set -l suite " - import plugins/fish-spec - - function describe_blank_suite - echo 'first describe' - end - - function describe_another_blank_suite - echo 'second describe' - end - - spec.run - " - - expect (run_nested_suite $suite) --to-contain-all 'first describe' 'second describe' - end - - function it_runs_all_it_blocks - set -l suite " - import plugins/fish-spec - - function describe_suite - function it_a_test - echo 'first test' - end - end - - function describe_another_suite - function it_another_test - echo 'second test' - end - end - - spec.run - " - - expect (run_nested_suite $suite) --to-contain-all 'first test' 'second test' - end - - function it_adds_a_dot_for_a_successful_expectation - set -l suite " - import plugins/fish-spec - - function describe_suite - function it_is_executed - expect 'success' --to-equal 'success' - end - end - - spec.run - " - - expect (run_nested_suite $suite) --to-equal (dot) - end - - function it_adds_a_dot_for_each_successful_test - set -l suite " - import plugins/fish-spec - - function describe_suite - function it_is_executed - expect 'success' --to-equal 'success' - end - - function it_is_executed_again - expect 'success' --to-equal 'success' - end - end - - spec.run - " - - expect (run_nested_suite $suite) --to-equal (dot)(dot) - end - - function it_only_adds_a_dot_once_for_each_successful_test - set -l suite " - import plugins/fish-spec - - function describe_suite - function it_is_executed - expect 'success' --to-equal 'success' - expect 'success' --to-equal 'success' - end - end - - spec.run - " - - expect (run_nested_suite $suite) --to-equal (dot) - end - - function it_allows_debugging_messages_to_be_echoed_inside_a_test - set -l suite " - import plugins/fish-spec - - function describe_suite - function it_is_executed - echo 'I can see this' - end - end - - spec.run - " - set -l output (run_nested_suite $suite) - expect "$output" --to-contain-all 'I can see this' - end -end - -function run_nested_suite -a suite - # Erase and backup original suite functions to avoid an infinite loop. - spec.functions -eb it_ describe_ -- "backup." - - # Run nested suite - eval $suite - set -l result $status - - # Erase functions created by the nested suite - spec.functions -e it_ describe_ - - # Restore original suite functions - spec.functions -re backup. - - return $result -end - -function dot - echo -ne (set_color 00FF7F). -end - -spec.run $argv diff --git a/plugins/omf/omf.fish b/plugins/omf/omf.fish deleted file mode 100644 index 3db2815..0000000 --- a/plugins/omf/omf.fish +++ /dev/null @@ -1,32 +0,0 @@ -# NAME -# omf - Oh My Fish helper -# -# DESCRIPTION -# Extend fish binary to support plugins and themes installation -# -function omf -d "Oh My Fish helper" - if test (count $argv) -gt 0 - switch $argv[1] - case 'install' - omf.packages --install - case 'update' - omf.packages --update - case 'list' 'ls' - 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 'plugins' - omf.packages --plugins - case 'themes' - omf.packages --themes - case '*' - omf.helper - end - else - omf.helper - end -end diff --git a/plugins/omf/omf.git.fish b/plugins/omf/omf.git.fish deleted file mode 100644 index 26abb71..0000000 --- a/plugins/omf/omf.git.fish +++ /dev/null @@ -1,16 +0,0 @@ -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 (pushd $path; and git pull --quiet --rebase > /dev/null - echo $status - popd > /dev/null) - case '*' - omf.log red 'Unknown option' - end -end diff --git a/plugins/omf/omf.helper.fish b/plugins/omf/omf.helper.fish deleted file mode 100644 index fe979e4..0000000 --- a/plugins/omf/omf.helper.fish +++ /dev/null @@ -1,18 +0,0 @@ -# NAME -# omf.helper - Prints Oh My Fish help -# -# DESCRIPTION -# Prints all functions supported by Oh My Fish helper -# -function omf.helper -d 'Prints all functions supported by Oh My Fish helper' - omf.log normal 'Oh My Fish is a package manager for fish shell. This is a' - omf.log normal 'basic help message containing pointers to more information.' - omf.log normal '' - omf.log normal ' Examples:' - omf.log normal ' omf install' - omf.log normal ' omf update' - omf.log normal ' omf list' - omf.log normal ' omf self-update' - omf.log normal ' omf plugins' - omf.log normal ' omf themes' -end diff --git a/plugins/omf/omf.log.fish b/plugins/omf/omf.log.fish deleted file mode 100644 index 7b17aab..0000000 --- a/plugins/omf/omf.log.fish +++ /dev/null @@ -1,17 +0,0 @@ -# NAME -# omf.log - simple log with color -# -# SYNOPSIS -# [...] -# -# DESCRIPTION -# Simply log a message with a specified color. -# -function omf.log -d "Simple log with color" - switch $argv[1] - case '-*' - echo $argv[1] (set_color $argv[2])$argv[3..-1](set_color normal) - case '*' - echo -e (set_color $argv[1])$argv[2..-1](set_color normal) - end -end diff --git a/plugins/omf/omf.packages.fish b/plugins/omf/omf.packages.fish deleted file mode 100644 index 192d038..0000000 --- a/plugins/omf/omf.packages.fish +++ /dev/null @@ -1,98 +0,0 @@ -# NAME -# omf.packages - Manage all plugins and themes -# -# SYNOPSIS -# omf.packages [OPTIONS] -# -# OPTIONS -# --install -# Install all packages -# --install --plugin|--theme NAME -# Install one theme/plugin -# --update -# Update all packages -# --list -# List all active packages -# --plugins -# List all plugins available from the oh-my-fish Github repository -# --themes -# List all themes available from the oh-my-fish Github repository -# -# DESCRIPTION -# Manage all plugins and themes specified on the $fish_plugins -# and $fish_theme variables -# -function omf.packages --argument-names options arg1 arg2 -d 'Manage all plugins and themes' - set -g __omf_packages_modified 0 - - switch $options - case '--install' - switch "$arg1" - case '--plugin' - omf.packages.install --plugin $arg2 - case '--theme' - omf.packages.install --theme $arg2 - case "" - for plugin in $fish_plugins - omf.packages.install --plugin $plugin - end - - omf.packages.install --theme $fish_theme - - if [ $__omf_packages_modified -eq 0 ] - omf.log green 'All packages were already installed.' - end - end - case '--update' - for plugin in $fish_plugins - omf.packages.update --plugin $plugin - end - - omf.packages.update --theme $fish_theme - - if [ $__omf_packages_modified -eq 0 ] - omf.log green 'All packages were already updated' - end - case '--list' - omf.log yellow 'Plugins: ' - if test -n "$fish_plugins" - omf.log normal $fish_plugins - end - - omf.log normal '' - omf.log yellow 'Theme: ' - if test -n "$fish_theme" - omf.log normal $fish_theme - end - case '--plugins' - omf.remote --plugins - case '--themes' - omf.remote --themes - case '*' - omf.log red 'Unknown option' - end -end - -function omf.packages.report.installing -e omf_package_installing - omf.log -n white "Installing $argv... " -end - -function omf.packages.report.updating -e omf_package_updating - omf.log -n white "Updating $argv... " -end - -function omf.packages.report.failed -e omf_package_install_failed -e omf_package_update_failed - omf.log red "✖" - - set_color yellow - cat /tmp/oh-my-fish.clone.log - echo -e '' - set_color normal - - set __omf_packages_modified (expr $__omf_packages_modified + 1) -end - -function omf.packages.report.finished -e omf_package_installed -e omf_package_updated - omf.log green "✔" - set __omf_packages_modified (expr $__omf_packages_modified + 1) -end diff --git a/plugins/omf/omf.packages.install.fish b/plugins/omf/omf.packages.install.fish deleted file mode 100644 index 727c2b9..0000000 --- a/plugins/omf/omf.packages.install.fish +++ /dev/null @@ -1,42 +0,0 @@ -# NAME -# omf.packages.install - Install a plugin or theme -# -# SYNOPSIS -# --plugin -# --theme -# -# DESCRIPTION -# Install a plugin or theme -# -function omf.packages.install --argument-names type name -d "Install a plugin or theme" - switch $type - case '--plugin' - if [ -e $fish_path/plugins/$name -o -e $fish_custom/plugins/$name ] - # Plugin is already installed. Skipping. - else - emit omf_package_installing $name - omf.git --clone "https://github.com/oh-my-fish/plugin-$name" $fish_path/plugins/$name - - if [ $status -eq 0 ] - emit omf_package_installed $name - else - emit omf_package_install_failed $name - end - end - case '--theme' - if [ -e $fish_path/themes/$name -o -e $fish_custom/themes/$name ] - # Theme is already installed. Skipping. - else - emit omf_package_installing $name - omf.git --clone "https://github.com/oh-my-fish/theme-$name" $fish_path/themes/$name - - if [ $status -eq 0 ] - emit omf_package_installed $name - else - emit omf_package_install_failed $name - end - end - case '*' - omf.log red 'Unknown option' - end -end diff --git a/plugins/omf/omf.packages.update.fish b/plugins/omf/omf.packages.update.fish deleted file mode 100644 index f9016ba..0000000 --- a/plugins/omf/omf.packages.update.fish +++ /dev/null @@ -1,48 +0,0 @@ -# NAME -# omf.packages.update - Update a plugin or theme -# -# SYNOPSIS -# --plugin -# --theme -# -# DESCRIPTION -# Update a plugin or theme -# -function omf.packages.update --argument-names type name -d "Update a plugin or theme" - pushd # Save current dir - - switch $type - case '--plugin' - if [ -e $fish_path/plugins/$name -a -e $fish_path/plugins/$name/.git ] - emit omf_package_updating $name - omf.git --update $fish_path/plugins/$name - emit omf_package_updated $name - else - if [ -e $fish_custom/plugins/$name -a -e $fish_custom/plugins/$name/.git ] - emit omf_package_updating $name - omf.git --update $fish_path/plugins/$name - emit omf_package_updated $name - else - # Plugin is not installed or not a git repo. Skipping. - end - end - case '--theme' - if [ -e $fish_path/themes/$name -a -e $fish_path/themes/$name/.git ] - emit omf_package_updating $name - omf.git --update $fish_path/themes/$name - emit omf_package_updated $name - else - if [ -e $fish_custom/themes/$name -a -e $fish_custom/themes/$name/.git ] - emit omf_package_updating $name - omf.git --update $fish_custom/themes/$name - emit omf_package_updated $name - else - # Theme is not installed or not a git repo. Skipping. - end - end - case '*' - omf.log red 'Unknown option' - end - - popd # Restore current dir -end diff --git a/plugins/omf/omf.remote.fish b/plugins/omf/omf.remote.fish deleted file mode 100644 index 00433af..0000000 --- a/plugins/omf/omf.remote.fish +++ /dev/null @@ -1,39 +0,0 @@ -# NAME -# omf.remote - List remote plugins and themes -# -# SYNOPSIS -# omf.remote [OPTIONS] -# -# OPTIONS -# --plugins -# List all available plugins -# --themes -# List all available themes -# -# DESCRIPTION -# List remote plugins and themes from the oh-my-fish Github repository -# -function omf.remote --argument-names options -d 'List remote plugins and themes' - set url "https://api.github.com/orgs/oh-my-fish/repos" - set page_count (curl -sI "$url?page=1&per_page=100" | grep "^Link" | sed 's/Link:.*page=\([0-9]*\)&per_page=100>; rel="last".*/\1/') - - if echo $page_count | grep -vE '^[0-9]+$' - echo "Could not access Github API" >&2 - return 1 - end - - set repos "" - for i in (seq $page_count) - set answer (curl -s "$url?page=$i&per_page=100" | grep '"name"' | tr '":' " " | awk '{print $2}') - set repos "$answer $repos" - end - - switch $options - case '--plugins' - echo $repos | tr ' ' "\\n" | grep "plugin-" | cut -d "-" -f 2- | sort | paste -sd " " - - case '--themes' - echo $repos | tr ' ' "\\n" | grep "theme-" | cut -d "-" -f 2- | sort | paste -sd " " - - case '*' - omf.log red 'Unknown option' - end -end diff --git a/script/bootstrap.sh b/script/bootstrap.sh deleted file mode 100755 index cb130b7..0000000 --- a/script/bootstrap.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -if [ "$TRAVIS_OS_NAME" = "linux" ]; then - ppa=ppa:fish-shell/$FISH_PPA - sudo add-apt-repository -y $ppa - sudo apt-get update - sudo apt-get -y install fish -else - brew install fish $BREW_OPTIONS -fi - -curl -L https://github.com/$TRAVIS_REPO_SLUG/raw/$TRAVIS_BRANCH/tools/install.fish | fish diff --git a/script/run-tests.fish b/script/run-tests.fish deleted file mode 100755 index f60adc0..0000000 --- a/script/run-tests.fish +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env fish - -set -l result 0 -for test in (find $fish_path -type f -print | grep "spec.fish") - fish $test $argv - or set result 1 -end -exit $result diff --git a/spec/import.spec.fish b/spec/import.spec.fish deleted file mode 100644 index 06d0fa2..0000000 --- a/spec/import.spec.fish +++ /dev/null @@ -1,47 +0,0 @@ -import plugins/fish-spec - -function describe_import - function before_all - set -g fish_function_path_bak $fish_function_path - - list.erase "$fish_path/plugins/archlinux" --from fish_function_path - list.erase "$fish_path/plugins/git-flow" --from fish_function_path - list.erase "$fish_path/plugins/tiny" --from fish_function_path - end - - function after_all - set fish_function_path $fish_function_path_bak - end - - function it_imports_all_fish_files - import plugins/tiny - expect $fish_function_path --to-contain-all $fish_path/plugins/tiny - end - - function it_imports_all_fish_files_recursively - import plugins/archlinux - expect $fish_function_path --to-contain-all $fish_path/plugins/archlinux/pacman - end - - function it_does_not_import_test_files - import plugins/tiny - expect $fish_function_path --to-not-contain-all $fish_path/plugins/spec - end - - function it_does_not_import_completion_files - import plugins/git-flow - expect $fish_function_path --to-not-contain-all $fish_path/plugins/git-flow/completions/ - end - - function it_adds_completion_files_to_completion_path - import plugins/git-flow - expect $fish_complete_path --to-contain-all $fish_path/plugins/git-flow/completions - end - - function it_adds_completion_files_for_custom_plugins_to_completion_path - import plugins/example - expect $fish_complete_path --to-contain-all $fish_custom/plugins/example/completions - end -end - -spec.run $argv diff --git a/spec/oh-my-fish.spec.fish b/spec/oh-my-fish.spec.fish deleted file mode 100755 index b0c3764..0000000 --- a/spec/oh-my-fish.spec.fish +++ /dev/null @@ -1,71 +0,0 @@ -import plugins/fish-spec - -function describe_oh_my_fish - function before_all - set -g fish_custom_bak $fish_custom - set -g fish_plugins_bak $fish_plugins - set -g fish_function_path_bak $fish_function_path - end - - function after_all - set fish_custom $fish_custom_bak - set fish_plugins $fish_plugins_bak - set fish_function_path $fish_function_path_bak - end - - function it_has_a_default_custom_directory - set -e fish_custom - load_oh_my_fish - expect $fish_custom --to-equal "$HOME/.oh-my-fish/custom" - end - - function it_allows_the_custom_folder_location_to_be_customized - set -g fish_custom /tmp - load_oh_my_fish - expect $fish_custom --to-equal '/tmp' - end - - function it_loads_all_custom_files - set -g fish_custom /tmp - echo 'set -gx TEST_LOAD_CUSTOM_FILE file_loaded' > $fish_custom/test.load - - load_oh_my_fish - expect $TEST_LOAD_CUSTOM_FILE --to-equal 'file_loaded' - end - - function it_loads_all_oh_my_fish_functions - list.erase "$fish_path/functions/" --from fish_function_path - - load_oh_my_fish - expect $fish_function_path --to-contain-all $fish_path/functions/ - end - - function it_loads_all_selected_plugins - list.erase "$fish_path/plugins/bak" \ - "$fish_path/plugins/z" --from fish_function_path - - set -g fish_plugins bak z - load_oh_my_fish - expect $fish_function_path --to-contain-all $fish_path/plugins/bak - expect $fish_function_path --to-contain-all $fish_path/plugins/z - end - - function it_loads_the_selected_theme - list.erase "$fish_path/themes/l" --from fish_function_path - - set fish_theme l - load_oh_my_fish - expect $fish_function_path --to-contain-all $fish_path/themes/l - end - - function it_reloads_with_status_of_0 - load_oh_my_fish - expect $status --to-equal 0 - end -end - -function load_oh_my_fish - . $fish_path/oh-my-fish.fish -end - -spec.run $argv diff --git a/templates/config.fish b/templates/config.fish deleted file mode 100644 index 9020cb0..0000000 --- a/templates/config.fish +++ /dev/null @@ -1,13 +0,0 @@ -# Path to your oh-my-fish. -set fish_path $HOME/.oh-my-fish - -# Path to your custom folder (default path is ~/.oh-my-fish/custom) -#set fish_custom $HOME/dotfiles/oh-my-fish - -# Load oh-my-fish configuration. -. $fish_path/oh-my-fish.fish - -# Custom plugins and themes may be added to ~/.oh-my-fish/custom -# Plugins and themes can be found at https://github.com/oh-my-fish/ -Theme 'robbyrussell' -Plugin 'theme' diff --git a/themes/.gitignore b/themes/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/tools/install.fish b/tools/install.fish deleted file mode 100644 index ee1c43c..0000000 --- a/tools/install.fish +++ /dev/null @@ -1,123 +0,0 @@ -#!/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/oh-my-fish/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 | TRAVIS_REPO_SLUG= 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 -#/ - -set fish_path ~/.oh-my-fish -set config_path ~/.config/fish - -# Log a color message. -# log ... -function log - echo -e (set_color $argv[1])$argv[2..-1](set_color normal) -end - -log white "Installing Oh My Fish..." - -# Allow installers to specify the source repository. -if not set -q TRAVIS_REPO_SLUG - set TRAVIS_REPO_SLUG oh-my-fish/oh-my-fish - set TRAVIS_BRANCH master -end - -# Abort installation if oh-my-fish is already installed. -if test -d $fish_path - log yellow "You already have Oh My Fish installed." - log white "Remove $fish_path if you want to reinstall it." - exit 1 -end - -# Either git clone or curl GET repository. -log blue "Cloning Oh My Fish from remote repository..." -if type git >/dev/null - git clone -b $TRAVIS_BRANCH "https://github.com/$TRAVIS_REPO_SLUG.git" $fish_path -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/$TRAVIS_REPO_SLUG/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/oh-my-fish/oh-my-fish/issues" - exit 1 - end -end - -# Check any existing config.fish files, backup and add custom template. -log blue "Looking for an existing fish config..." -if test -f $config_path/config.fish - 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. -log green \ -" _ - | | - ___ | |__ _ __ ___ _ _ - / _ \| _ \ | _ ` _ \| | | | - | (_) | | | | | | | | | | |_| | - \___/|_| |_| |_| |_| |_|\__, | - __/ | - |___/ -" - -echo " "(set_color F00)"___ - ___======____="(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)\n\n - -log green "...is now installed." - -# 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