From 7023aed6ec5b4a21e6338019bff54271d4c4c914 Mon Sep 17 00:00:00 2001 From: Derek Stavis <dekestavis@gmail.com> Date: Wed, 10 Feb 2016 21:41:44 -0200 Subject: [PATCH] lib: remove legacy code --- lib/README.md | 82 ------------------------------------ lib/autoload.fish | 58 ------------------------- lib/available.fish | 9 ---- lib/completions/.gitkeep | 0 lib/git/git_ahead.fish | 18 -------- 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 | 12 ------ lib/require.fish | 41 ------------------ 15 files changed, 275 deletions(-) delete mode 100644 lib/README.md delete mode 100644 lib/autoload.fish delete mode 100644 lib/available.fish delete mode 100644 lib/completions/.gitkeep delete mode 100644 lib/git/git_ahead.fish delete mode 100644 lib/git/git_branch_name.fish delete mode 100644 lib/git/git_is_dirty.fish delete mode 100644 lib/git/git_is_repo.fish delete mode 100644 lib/git/git_is_staged.fish delete mode 100644 lib/git/git_is_stashed.fish delete mode 100644 lib/git/git_is_touched.fish delete mode 100644 lib/git/git_untracked.fish delete mode 100644 lib/prompt_segments.fish delete mode 100644 lib/refresh.fish delete mode 100644 lib/require.fish diff --git a/lib/README.md b/lib/README.md deleted file mode 100644 index f9c0c1e..0000000 --- a/lib/README.md +++ /dev/null @@ -1,82 +0,0 @@ -<p align="center"> - <a href="https://github.com/oh-my-fish/oh-my-fish/blob/master/README.md"> - <img width="100px" src="https://cloud.githubusercontent.com/assets/8317250/8510172/f006f0a4-230f-11e5-98b6-5c2e3c87088f.png"> - </a> -</p> - -# Core Library - -## Basic Functions - -#### `autoload` _`[-e] <path>...`_ - -Manipulate [autoloading](http://fishshell.com/docs/current/index.html#syntax-function-autoloading) path components. - -All paths ending with `completions` are correctly added to or erased from -`$fish_complete_path`. - -To add paths to autoload: - -```fish -autoload $mypath $mypath/completions -``` - -To erase paths from autoload: - -```fish -autoload -e $mypath $mypath/completions -``` - -#### `available` _`<name>`_ - -Check if a program is available to run. Sets `$status` to `0` if the program is available. - -Use this function to check if a plugin is available before using it: - -```fish -if available battery - battery -end -``` - -#### `refresh` - -Replace the running instance of fishshell with a new one causing Oh My Fish to reload as well. - -#### `prompt_segments` - -Extract the root (top-most parent directory), dirname and basename from [`fish_prompt`](http://fishshell.com/docs/current/faq.html#faq-prompt). - -## 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 deleted file mode 100644 index c5312eb..0000000 --- a/lib/autoload.fish +++ /dev/null @@ -1,58 +0,0 @@ -# SYNOPSIS -# autoload <path>... -# autoload -e <path>... -# -# OVERVIEW -# Manipulate autoloading path components. -# -# If called without options, the paths passed as arguments are added to -# $fish_function_path. All paths ending with `completions` are correctly -# added to $fish_complete_path. Returns 0 if one or more paths exist. If all -# paths are missing, returns != 0. -# -# When called with -e, the paths passed as arguments are removed from -# $fish_function_path. All arguments ending with `completions` are correctly -# removed from $fish_complete_path. Returns 0 if one or more paths erased. If -# no paths were erased, returns != 0. - -function autoload -d "Manipulate autoloading path components" - set -l paths $argv - - switch "$argv[1]" - case '-e' '--erase' - set erase - - if test (count $argv) -ge 2 - set paths $argv[2..-1] - else - echo "usage: autoload $argv[1] <path>..." 1>&2 - return 1 - end - case "-*" "--*" - echo "autoload: invalid option $argv[1]" - return 1 - end - - for path in $paths - not test -d "$path"; and continue - - set -l dest fish_function_path - - if test (basename "$path") = completions - set dest fish_complete_path - end - - if set -q erase - if set -l index (contains -i -- $path $$dest) - set -e {$dest}[$index] - set return_success - end - else - set return_success - contains -- "$path" $$dest; and continue - set $dest "$path" $$dest - end - end - - set -q return_success -end diff --git a/lib/available.fish b/lib/available.fish deleted file mode 100644 index b6cfa14..0000000 --- a/lib/available.fish +++ /dev/null @@ -1,9 +0,0 @@ -# SYNOPSIS -# available [name] -# -# OVERVIEW -# Check if a function or program is available. - -function available -a name -d "Check if a function or program is available." - type "$name" ^/dev/null >&2 -end diff --git a/lib/completions/.gitkeep b/lib/completions/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/lib/git/git_ahead.fish b/lib/git/git_ahead.fish deleted file mode 100644 index 59ea054..0000000 --- a/lib/git/git_ahead.fish +++ /dev/null @@ -1,18 +0,0 @@ -function git_ahead -a ahead behind diverged none - not git_is_repo; and return - - set -l commit_count (command git rev-list --count --left-right "@{upstream}...HEAD" ^/dev/null) - - switch "$commit_count" - case "" - # no upstream - case "0"\t"0" - test -n "$none"; and echo "$none"; or echo "" - case "*"\t"0" - test -n "$behind"; and echo "$behind"; or echo "-" - case "0"\t"*" - test -n "$ahead"; and echo "$ahead"; or echo "+" - case "*" - test -n "$diverged"; and echo "$diverged"; or echo "±" - end -end diff --git a/lib/git/git_branch_name.fish b/lib/git/git_branch_name.fish deleted file mode 100644 index 557b3b9..0000000 --- a/lib/git/git_branch_name.fish +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 282d911..0000000 --- a/lib/git/git_is_dirty.fish +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index df5874d..0000000 --- a/lib/git/git_is_repo.fish +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index e26f34a..0000000 --- a/lib/git/git_is_staged.fish +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index da190ef..0000000 --- a/lib/git/git_is_stashed.fish +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 172f605..0000000 --- a/lib/git/git_is_touched.fish +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index fe7dcd5..0000000 --- a/lib/git/git_untracked.fish +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index bdf10b9..0000000 --- a/lib/prompt_segments.fish +++ /dev/null @@ -1,24 +0,0 @@ -# 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 deleted file mode 100644 index d6b8dce..0000000 --- a/lib/refresh.fish +++ /dev/null @@ -1,12 +0,0 @@ -# SYNOPSIS -# refresh -# -# OVERVIEW -# Refresh (reload) the current fish session. - -function refresh -d "Refresh fish session by replacing current process" - if not set -q CI - history --save - exec fish < /dev/tty - end -end diff --git a/lib/require.fish b/lib/require.fish deleted file mode 100644 index db7c959..0000000 --- a/lib/require.fish +++ /dev/null @@ -1,41 +0,0 @@ -# SYNOPSIS -# require [name] -# -# OVERVIEW -# Require a plugin: -# - Autoload its functions and completions. -# - Require bundle dependencies. -# - Source its initialization file. -# - Emit its initialization event. -# -# If the required plugin has already been loaded, does nothing. - -function require -a name - # Skip if plugin has already been loaded. - contains -- $OMF_PATH/pkg/$name $fish_function_path; - or contains -- $OMF_CONFIG/pkg/$name $fish_function_path; - and return 0 - - for path in {$OMF_PATH,$OMF_CONFIG}/pkg/$name - test -d $path; or continue - - if autoload $path $path/functions $path/completions - - if test -f $path/bundle - for line in (cat $path/bundle) - test (echo $line | cut -d' ' -f1) = package; - and set dependency (basename (echo $line | cut -d' ' -f2)); - and require $dependency - end - end - - source $path/init.fish ^/dev/null; - or source $path/$name.fish ^/dev/null; - and emit init_$name $path - end - end - - functions -e init # Cleanup previously sourced function - - return 0 -end -- GitLab