Migrate to rcm

This commit is contained in:
2020-08-12 02:29:03 +04:00
parent d1b5037e15
commit 547a5b9f84
334 changed files with 3905 additions and 4270 deletions

View File

@@ -0,0 +1 @@
fisher complete

View File

@@ -0,0 +1,6 @@
function __kitty_completions
# Send all words up to the one before the cursor
commandline -cop | kitty +complete fish
end
complete -f -c kitty -a "(__kitty_completions)"

View File

@@ -0,0 +1,320 @@
# Taskwarrior completions for the Fish shell <http://fishshell.org>
#
# taskwarrior - a command line task list manager.
#
# Completions should work out of box. If it isn't, fill the bug report on your
# operation system bug tracker.
#
# As a workaround you can copy this script to
# ~/.config/fish/completions/task.fish, and open a new shell.
#
# Objects completed:
# * Commands
# * Projects
# * Priorities
# * Tags
# * Attribute names and modifiers
#
#
# You can override some default options in your config.fish:
#
# # Tab-completion of task descriptions.
# # Warning: This often creates a list of suggestions which spans several pages,
# # and it usually pushes some of the commands and attributes to the end of the
# # list.
# set -g task_complete_task yes
#
# # Tab-completion of task IDs outside of the "depends" attribute.
# # Warning: This often creates a list of suggestions which spans several pages,
# # and it pushes all commands and attributes to the end of the list.
# set -g task_complete_id yes
#
# # Attribute modifiers (DEPRECATED since 2.4.0)
# set -g task_complete_attribute_modifiers yes
#
#
# Copyright 2014 - 2019, Roman Inflianskas <infroma@gmail.com>
#
# 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.
#
# https://www.opensource.org/licenses/mit-license.php
# NOTE: remember that sed on OS X is different in some aspects. E.g. it does
# not understand \t for tabs.
# convinience functions
function __fish.task.log
for line in $argv
echo $line >&2
end
end
function __fish.task.partial
set wrapped $argv[1]
set what $argv[2]
set -q argv[3]; and set f_argv $argv[3..-1]
set f __fish.task.$wrapped.$what
functions -q $f; and eval $f $f_argv
end
function __fish.task.zsh
set -q argv[2]; and set task_argv $argv[2..-1]
task _zsh$argv[1] $task_argv | sed 's/:/ /'
end
# command line state detection
function __fish.task.bare
test (count (commandline -c -o)) -eq 1
end
function __fish.task.current.command
# find command in commandline by list intersection
begin; commandline -pco; and __fish.task.list._command all | cut -d ' ' -f 1; end | sort | uniq -d | xargs
end
function __fish.task.before_command
test -z (__fish.task.current.command)
end
# checking need to complete
function __fish.task.need_to_complete.attr_name
__fish.task.need_to_complete.filter; or contains (__fish.task.current.command) (__fish.task.list.command_mods)
end
function __fish.task.need_to_complete.attr_value
__fish.task.need_to_complete.attr_name
end
function __fish.task.need_to_complete.command
switch $argv
case all
__fish.task.bare
case filter
__fish.task.before_command
end
end
function __fish.task.need_to_complete.config
contains (__fish.task.current.command) 'config' 'show'
end
function __fish.task.need_to_complete.filter
__fish.task.before_command
end
function __fish.task.need_to_complete.id
__fish.task.need_to_complete.filter
end
function __fish.task.need_to_complete.task
__fish.task.need_to_complete.filter
end
function __fish.task.need_to_complete
__fish.task.partial need_to_complete $argv
end
# list printers
function __fish.task.token_clean
sed 's/[^a-z_.]//g; s/^\.$//g'
end
function __fish.task.list.attr_name
task _columns | sed 's/$/: attribute/g'
# BUG: doesn't support file completion
echo rc
end
function __fish.task.list.attr_value
set token (commandline -ct | cut -d ':' -f 1 | cut -d '.' -f 1 | __fish.task.token_clean)
if test -n $token
set attr_names (__fish.task.list.attr_name | sed 's/: / /g' | grep '^'$token | cut -d ' ' -f 1)
for attr_name in $attr_names
if test -n $attr_name
__fish.task.list.attr_value_by_name $attr_name
end
end
end
__fish.task.list.tag
end
function __fish.task.list.attr_value_by_name
set attr $argv[1]
switch $attr
case 'rc'
__fish.task.list.rc
case 'depends' 'limit' 'priority' 'status'
__fish.task.combos_simple $attr (__fish.task.list $attr)
# case 'description' 'due' 'entry' 'end' 'start' 'project' 'recur' 'until' 'wait'
case '*'
if [ "$task_complete_attribute_modifiers" = 'yes' ]; and echo (commandline -ct) | grep -q '\.'
__fish.task.combos_with_mods $attr (__fish.task.list $attr)
else
__fish.task.combos_simple $attr (__fish.task.list $attr)
end
end
end
function __fish.task.list._command
# Removed args until TW-1404 is fixed.
#__fish.task.zsh commands $argv
__fish.task.zsh commands
end
function __fish.task.list.command
# ignore special commands
__fish.task.list._command $argv | command grep -Ev '^_'
end
function __fish.task.list.command_mods
for command in 'add' 'annotate' 'append' 'delete' 'done' 'duplicate' 'log' 'modify' 'prepend' 'start' 'stop'
echo $command
end
end
function __fish.task.list.config
task _config
end
function __fish.task.list.depends
__fish.task.list.id with_description
end
function __fish.task.list.description
__fish.task.zsh ids $argv | cut -d ' ' -f 2-
end
function __fish.task.list.id
set show_type $argv[1]
if test -z $show_type
task _ids
else if [ $show_type = 'with_description' ]
__fish.task.zsh ids
end
end
# Attribure modifiers (DEPRECATED since 2.4.0)
function __fish.task.list.mod
for mod in 'before' 'after' 'over' 'under' 'none' 'is' 'isnt' 'has' 'hasnt' 'startswith' 'endswith' 'word' 'noword'
echo $mod
end
end
function __fish.task.list.priority
for priority in 'H' 'M' 'L'
echo $priority
end
end
function __fish.task.list.project
task _projects
end
function __fish.task.list.rc
for value in (task _config)
echo rc.$value:
end
end
function __fish.task.list.status
echo pending
echo completed
echo deleted
echo waiting
end
function __fish.task.list.tag
for tag in (task _tags)
echo +$tag
echo -$tag
end
end
function __fish.task.list.task
__fish.task.zsh ids | sed -E 's/^(.*) (.*)$/\2 task [id = \1]/g'
end
function __fish.task.list
__fish.task.partial list $argv
end
function __fish.task.results_var_name
echo $argv | sed 's/^/__fish.task.list /g; s/$/ results/g; s/[ .]/_/g;'
end
function __fish.task.list_results
set var_name (__fish.task.results_var_name $name)
for line in $$var_name
echo $line
end
end
# working with attributes
function __fish.task.combos_simple
set attr_name $argv[1]
set -q argv[2]; and set attr_values $argv[2..-1]
if [ (count $attr_values) -gt 0 ]
for attr_value in $attr_values
echo "$attr_name:$attr_value"
end
else
echo "$attr_name:"
end
end
# Attribure modifiers (DEPRECATED since 2.4.0)
function __fish.task.combos_with_mods
__fish.task.combos_simple $argv
for mod in (__fish.task.list.mod)
__fish.task.combos_simple $argv[1].$mod $argv[2..-1]
end
end
# actual completion
function __fish.task.complete
set what $argv
set list_command "__fish.task.list $what"
set check_function "__fish.task.need_to_complete $what"
complete -c task -u -f -n $check_function -a "(eval $list_command)"
end
__fish.task.complete command all
__fish.task.complete command filter
__fish.task.complete attr_value
__fish.task.complete attr_name
__fish.task.complete config
if [ "$task_complete_task" = 'yes' ]
__fish.task.complete task
end
if [ "$task_complete_id" = 'yes' ]
__fish.task.complete id with_description
end

View File

@@ -0,0 +1,38 @@
# aliases
alias sdr="screen -aAdr"
alias ls='exa'
alias la="exa -a"
alias ll="exa -laF"
alias mkpasswd="head -c16 /dev/urandom | xxd -ps"
alias mc="mc -b"
alias cdp='cd (~/bin/cdp); clear'
if command -sq grc
alias ping="grc --colour=auto ping"
alias traceroute="grc --colour=auto traceroute"
alias make="grc --colour=auto make"
alias diff="grc --colour=auto diff"
alias cvs="grc --colour=auto cvs"
alias netstat="grc --colour=auto netstat"
alias mount="grc --colour=auto mount"
alias ifconfig="grc --colour=auto ifconfig"
alias dig="grc --colour=auto dig"
alias ps="grc --colour=auto ps"
end
alias rgrep="grep --exclude-dir=Godeps --exclude-dir=node_modules --exclude-dir=log --exclude-dir=vendor --exclude-dir=tmp --exclude-dir=public --exclude-dir=.git --exclude=.swp -rn"
alias grep="grep --exclude-dir=.git --color=auto"
alias ag="ag --path-to-ignore $HOME/.agignore --nogroup"
alias vim="nvim"
# Typos
alias igt="git"
alias gti="git"
alias gitst="git st"
# Ledger
# alias ledger="noglob ledger"
# alias "bin/ledger"="noglob bin/ledger"
#
# alias icat="kitty +kitten icat"

View File

@@ -0,0 +1,14 @@
set -q FZF_TMUX_HEIGHT; or set -U FZF_TMUX_HEIGHT "40%"
set -q FZF_DEFAULT_OPTS; or set -U FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT"
set -q FZF_LEGACY_KEYBINDINGS; or set -U FZF_LEGACY_KEYBINDINGS 1
set -q FZF_PREVIEW_FILE_CMD; or set -U FZF_PREVIEW_FILE_CMD "head -n 10"
set -q FZF_PREVIEW_DIR_CMD; or set -U FZF_PREVIEW_DIR_CMD "ls"
function fzf_uninstall -e fzf_uninstall
# disabled until we figure out a sensible way to ensure user overrides
# are not erased
# set -l _vars (set | command grep -E "^FZF.*\$" | command awk '{print $1;}')
# for var in $_vars
# eval (set -e $var)
# end
end

View File

@@ -0,0 +1,49 @@
if test "$FZF_LEGACY_KEYBINDINGS" -eq 1
bind \ct '__fzf_find_file'
bind \cr '__fzf_reverse_isearch'
bind \ec '__fzf_cd'
bind \eC '__fzf_cd --hidden'
bind \cg '__fzf_open'
bind \co '__fzf_open --editor'
if bind -M insert >/dev/null 2>/dev/null
bind -M insert \ct '__fzf_find_file'
bind -M insert \cr '__fzf_reverse_isearch'
bind -M insert \ec '__fzf_cd'
bind -M insert \eC '__fzf_cd --hidden'
bind -M insert \cg '__fzf_open'
bind -M insert \co '__fzf_open --editor'
end
else
bind \cf '__fzf_find_file'
bind \cr '__fzf_reverse_isearch'
bind \eo '__fzf_cd'
bind \eO '__fzf_cd --hidden'
bind \cg '__fzf_open'
bind \co '__fzf_open --editor'
if bind -M insert >/dev/null 2>/dev/null
bind -M insert \cf '__fzf_find_file'
bind -M insert \cr '__fzf_reverse_isearch'
bind -M insert \eo '__fzf_cd'
bind -M insert \eO '__fzf_cd --hidden'
bind -M insert \cg '__fzf_open'
bind -M insert \co '__fzf_open --editor'
end
end
if set -q FZF_COMPLETE
bind \t '__fzf_complete'
if bind -M insert >/dev/null 2>/dev/null
bind -M insert \t '__fzf_complete'
end
end
function fzf_key_bindings_uninstall -e fzf_key_bindings_uninstall
# disabled until we figure out a sensible way to ensure user overrides
# are not erased
# set -l _bindings (bind -a | sed -En "s/(')?__fzf.*\$//p" | sed 's/bind/bind -e/')
# for binding in $_bindings
# eval $binding
# end
end

5
config/fish/config.fish Normal file
View File

@@ -0,0 +1,5 @@
#!/bin/fish
# direnv
set -x DIRENV_LOG_FORMAT ""
direnv hook fish | source

View File

@@ -0,0 +1,39 @@
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR FZF_DEFAULT_OPTS:\x2d\x2dheight\x2040\x25
SETUVAR FZF_LEGACY_KEYBINDINGS:1
SETUVAR FZF_PREVIEW_DIR_CMD:ls
SETUVAR FZF_PREVIEW_FILE_CMD:head\x20\x2dn\x2010
SETUVAR FZF_TMUX_HEIGHT:40\x25
SETUVAR __fish_init_2_39_8:\x1d
SETUVAR __fish_init_2_3_0:\x1d
SETUVAR __fish_init_3_x:\x1d
SETUVAR fish_color_autosuggestion:969896
SETUVAR fish_color_cancel:\x2dr
SETUVAR fish_color_command:7aa6da
SETUVAR fish_color_comment:2a2a2a
SETUVAR fish_color_cwd:green
SETUVAR fish_color_cwd_root:red
SETUVAR fish_color_end:e7c547
SETUVAR fish_color_error:d54e53
SETUVAR fish_color_escape:00a6b2
SETUVAR fish_color_history_current:\x2d\x2dbold
SETUVAR fish_color_host:normal
SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue
SETUVAR fish_color_normal:normal
SETUVAR fish_color_operator:00a6b2
SETUVAR fish_color_param:b9ca4a
SETUVAR fish_color_quote:e78c45
SETUVAR fish_color_redirection:c397d8
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_status:red
SETUVAR fish_color_user:brgreen
SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_greeting:\x1d
SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_completion:normal
SETUVAR fish_pager_color_description:B3A06D\x1eyellow
SETUVAR fish_pager_color_prefix:white\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
SETUVAR pure_version:2\x2e1\x2e8

3
config/fish/fishfile Normal file
View File

@@ -0,0 +1,3 @@
rbenv/fish-rbenv
jethrokuan/fzf
jorgebucaran/fish-spark

View File

@@ -0,0 +1,49 @@
function __fzf_cd -d "Change directory"
set -l commandline (__fzf_parse_commandline)
set -l dir $commandline[1]
set -l fzf_query $commandline[2]
if not type -q argparse
# Fallback for fish shell version < 2.7
function argparse
functions -e argparse # deletes itself
end
if contains -- --hidden $argv; or contains -- -h $argv
set _flag_hidden "yes"
end
end
# Fish shell version >= v2.7, use argparse
set -l options "h/hidden"
argparse $options -- $argv
set -l COMMAND
set -q FZF_CD_COMMAND
or set -l FZF_CD_COMMAND "
command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \
-o -type d -print 2> /dev/null | sed 's@^\./@@'"
set -q FZF_CD_WITH_HIDDEN_COMMAND
or set -l FZF_CD_WITH_HIDDEN_COMMAND "
command find -L \$dir \
\\( -path '*/\\.git*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \
-o -type d -print 2> /dev/null | sed 1d | cut -b3-"
if set -q _flag_hidden
set COMMAND $FZF_CD_WITH_HIDDEN_COMMAND
else
set COMMAND $FZF_CD_COMMAND
end
eval "$COMMAND | "(__fzfcmd)" +m $FZF_DEFAULT_OPTS $FZF_CD_OPTS --query \"$fzf_query\"" | read -l select
if not test -z "$select"
builtin cd "$select"
# Remove last token from commandline.
commandline -t ""
end
commandline -f repaint
end

View File

@@ -0,0 +1,169 @@
##
# Use fzf as fish completion widget.
#
#
# When FZF_COMPLETE variable is set, fzf is used as completion
# widget for the fish shell by binding the TAB key.
#
# FZF_COMPLETE can have some special numeric values:
#
# `set FZF_COMPLETE 0` basic widget accepts with TAB key
# `set FZF_COMPLETE 1` extends 0 with candidate preview window
# `set FZF_COMPLETE 2` same as 1 but TAB walks on candidates
# `set FZF_COMPLETE 3` multi TAB selection, RETURN accepts selected ones.
#
# Any other value of FZF_COMPLETE is given directly as options to fzf.
#
# If you prefer to set more advanced options, take a look at the
# `__fzf_complete_opts` function and override that in your environment.
# modified from https://github.com/junegunn/fzf/wiki/Examples-(fish)#completion
function __fzf_complete -d 'fzf completion and print selection back to commandline'
# As of 2.6, fish's "complete" function does not understand
# subcommands. Instead, we use the same hack as __fish_complete_subcommand and
# extract the subcommand manually.
set -l cmd (commandline -co) (commandline -ct)
switch $cmd[1]
case env sudo
for i in (seq 2 (count $cmd))
switch $cmd[$i]
case '-*'
case '*=*'
case '*'
set cmd $cmd[$i..-1]
break
end
end
end
set -l cmd_lastw $cmd[-1]
set cmd (string join -- ' ' $cmd)
set -l initial_query ''
test -n "$cmd_lastw"; and set initial_query --query="$cmd_lastw"
set -l complist (complete -C$cmd)
set -l result
# do nothing if there is nothing to select from
test -z "$complist"; and return
set -l compwc (echo $complist | wc -w)
if test $compwc -eq 1
# if there is only one option dont open fzf
set result "$complist"
else
set -l query
string join -- \n $complist \
| sort \
| eval (__fzfcmd) (string escape --no-quoted -- $initial_query) --print-query (__fzf_complete_opts) \
| cut -f1 \
| while read -l r
# first line is the user entered query
if test -z "$query"
set query $r
# rest of lines are selected candidates
else
set result $result $r
end
end
# exit if user canceled
if test -z "$query" ;and test -z "$result"
commandline -f repaint
return
end
# if user accepted but no candidate matches, use the input as result
if test -z "$result"
set result $query
end
end
set prefix (string sub -s 1 -l 1 -- (commandline -t))
for i in (seq (count $result))
set -l r $result[$i]
switch $prefix
case "'"
commandline -t -- (string escape -- $r)
case '"'
if string match '*"*' -- $r >/dev/null
commandline -t -- (string escape -- $r)
else
commandline -t -- '"'$r'"'
end
case '~'
commandline -t -- (string sub -s 2 (string escape -n -- $r))
case '*'
commandline -t -- $r
end
[ $i -lt (count $result) ]; and commandline -i ' '
end
commandline -f repaint
end
function __fzf_complete_opts_common
if set -q FZF_DEFAULT_OPTS
echo $FZF_DEFAULT_OPTS
end
echo --cycle --reverse --inline-info
end
function __fzf_complete_opts_tab_accepts
echo --bind tab:accept,btab:cancel
end
function __fzf_complete_opts_tab_walks
echo --bind tab:down,btab:up
end
function __fzf_complete_opts_preview
set -l file (status -f)
echo --with-nth=1 --preview-window=right:wrap --preview="fish\ '$file'\ __fzf_complete_preview\ '{1}'\ '{2..}'"
end
test "$argv[1]" = "__fzf_complete_preview"; and __fzf_complete_preview $argv[2..3]
function __fzf_complete_opts_0 -d 'basic single selection with tab accept'
__fzf_complete_opts_common
echo --no-multi
__fzf_complete_opts_tab_accepts
end
function __fzf_complete_opts_1 -d 'single selection with preview and tab accept'
__fzf_complete_opts_0
__fzf_complete_opts_preview
end
function __fzf_complete_opts_2 -d 'single selection with preview and tab walks'
__fzf_complete_opts_1
__fzf_complete_opts_tab_walks
end
function __fzf_complete_opts_3 -d 'multi selection with preview'
__fzf_complete_opts_common
echo --multi
__fzf_complete_opts_preview
end
function __fzf_complete_opts -d 'fzf options for fish tab completion'
switch $FZF_COMPLETE
case 0
__fzf_complete_opts_0
case 1
__fzf_complete_opts_1
case 2
__fzf_complete_opts_2
case 3
__fzf_complete_opts_3
case '*'
echo $FZF_COMPLETE
end
if set -q FZF_COMPLETE_OPTS
echo $FZF_COMPLETE_OPTS
end
end

View File

@@ -0,0 +1,31 @@
function __fzf_complete_preview -d 'generate preview for completion widget.
argv[1] is the currently selected candidate in fzf
argv[2] is a string containing the rest of the output produced by `complete -Ccmd`
'
if test "$argv[2]" = "Redefine variable"
# show environment variables current value
set -l evar (echo $argv[1] | cut -d= -f1)
echo $argv[1]$$evar
else
echo $argv[1]
end
set -l path (string replace "~" $HOME -- $argv[1])
# list directories on preview
if test -d "$path"
eval $FZF_PREVIEW_DIR_CMD (string escape $path)
end
# show ten lines of non-binary files preview
if test -f "$path"; and grep -qI . "$path"
eval $FZF_PREVIEW_FILE_CMD (string escape $path)
end
# if fish knows about it, let it show info
type -q "$path" 2>/dev/null; and type -a "$path"
# show aditional data
echo $argv[2]
end

View File

@@ -0,0 +1,29 @@
function __fzf_find_file -d "List files and folders"
set -l commandline (__fzf_parse_commandline)
set -l dir $commandline[1]
set -l fzf_query $commandline[2]
set -q FZF_FIND_FILE_COMMAND
or set -l FZF_FIND_FILE_COMMAND "
command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | sed 's@^\./@@'"
begin
eval "$FZF_FIND_FILE_COMMAND | "(__fzfcmd) "-m $FZF_DEFAULT_OPTS $FZF_FIND_FILE_OPTS --query \"$fzf_query\"" | while read -l s; set results $results $s; end
end
if test -z "$results"
commandline -f repaint
return
else
commandline -t ""
end
for result in $results
commandline -it -- (string escape $result)
commandline -it -- " "
end
commandline -f repaint
end

View File

@@ -0,0 +1,17 @@
function __fzf_get_dir -d 'Find the longest existing filepath from input string'
set dir $argv
# Strip all trailing slashes. Ignore if $dir is root dir (/)
if [ (string length $dir) -gt 1 ]
set dir (string replace -r '/*$' '' $dir)
end
# Iteratively check if dir exists and strip tail end of path
while [ ! -d "$dir" ]
# If path is absolute, this can keep going until ends up at /
# If path is relative, this can keep going until entire input is consumed, dirname returns "."
set dir (dirname "$dir")
end
echo $dir
end

View File

@@ -0,0 +1,63 @@
function __fzf_open -d "Open files and directories."
function __fzf_open_get_open_cmd -d "Find appropriate open command."
if type -q xdg-open
echo "xdg-open"
else if type -q open
echo "open"
end
end
set -l commandline (__fzf_parse_commandline)
set -l dir $commandline[1]
set -l fzf_query $commandline[2]
if not type -q argparse
set created_argparse
function argparse
functions -e argparse # deletes itself
end
if contains -- --editor $argv; or contains -- -e $argv
set _flag_editor "yes"
end
if contains -- --preview $argv; or contains -- -p $argv
set _flag_preview "yes"
end
end
set -l options "e/editor" "p/preview=?"
argparse $options -- $argv
set -l preview_cmd
if set -q FZF_ENABLE_OPEN_PREVIEW
set preview_cmd "--preview-window=right:wrap --preview='fish -c \"__fzf_complete_preview {}\"'"
end
set -q FZF_OPEN_COMMAND
or set -l FZF_OPEN_COMMAND "
command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \
-o -type f -print \
-o -type d -print \
-o -type l -print 2> /dev/null | sed 's@^\./@@'"
eval "$FZF_OPEN_COMMAND | "(__fzfcmd) $preview_cmd "-m $FZF_DEFAULT_OPTS $FZF_OPEN_OPTS --query \"$fzf_query\"" | read -l select
# set how to open
set -l open_cmd
if set -q _flag_editor
set open_cmd "$EDITOR"
else
set open_cmd (__fzf_open_get_open_cmd)
if test -z "$open_cmd"
echo "Couldn't find appropriate open command to use. Do you have 'xdg-open' or 'open' installed?"; and return 1
end
end
set -l open_status 0
if not test -z "$select"
commandline "$open_cmd \"$select\"" ;and commandline -f execute
set open_status $status
end
commandline -f repaint
return $open_status
end

View File

@@ -0,0 +1,23 @@
function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath and rest of token'
# eval is used to do shell expansion on paths
set -l commandline (eval "printf '%s' "(commandline -t))
if [ -z $commandline ]
# Default to current directory with no --query
set dir '.'
set fzf_query ''
else
set dir (__fzf_get_dir $commandline)
if [ "$dir" = "." -a (string sub -l 1 $commandline) != '.' ]
# if $dir is "." but commandline is not a relative path, this means no file path found
set fzf_query $commandline
else
# Also remove trailing slash after dir, to "split" input properly
set fzf_query (string replace -r "^$dir/?" '' "$commandline")
end
end
echo $dir
echo $fzf_query
end

View File

@@ -0,0 +1,6 @@
function __fzf_reverse_isearch
history merge
history -z | eval (__fzfcmd) --read0 --tiebreak=index --toggle-sort=ctrl-r $FZF_DEFAULT_OPTS $FZF_REVERSE_ISEARCH_OPTS -q '(commandline)' | perl -pe 'chomp if eof' | read -lz result
and commandline -- $result
commandline -f repaint
end

View File

@@ -0,0 +1,9 @@
function __fzfcmd
set -q FZF_TMUX; or set FZF_TMUX 0
set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%
if [ $FZF_TMUX -eq 1 ]
echo "fzf-tmux -d$FZF_TMUX_HEIGHT"
else
echo "fzf"
end
end

View File

@@ -0,0 +1,97 @@
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
end
if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
end
if not set -q __fish_git_prompt_color_branch
set -g __fish_git_prompt_color_branch magenta --bold
end
if not set -q __fish_git_prompt_showupstream
set -g __fish_git_prompt_showupstream "informative"
end
if not set -q __fish_git_prompt_char_upstream_ahead
set -g __fish_git_prompt_char_upstream_ahead "↑"
end
if not set -q __fish_git_prompt_char_upstream_behind
set -g __fish_git_prompt_char_upstream_behind "↓"
end
if not set -q __fish_git_prompt_char_upstream_prefix
set -g __fish_git_prompt_char_upstream_prefix ""
end
if not set -q __fish_git_prompt_char_stagedstate
set -g __fish_git_prompt_char_stagedstate "●"
end
if not set -q __fish_git_prompt_char_dirtystate
set -g __fish_git_prompt_char_dirtystate "✚"
end
if not set -q __fish_git_prompt_char_untrackedfiles
set -g __fish_git_prompt_char_untrackedfiles "…"
end
if not set -q __fish_git_prompt_char_invalidstate
set -g __fish_git_prompt_char_invalidstate "✖"
end
if not set -q __fish_git_prompt_char_cleanstate
set -g __fish_git_prompt_char_cleanstate "✔"
end
if not set -q __fish_git_prompt_color_dirtystate
set -g __fish_git_prompt_color_dirtystate blue
end
if not set -q __fish_git_prompt_color_stagedstate
set -g __fish_git_prompt_color_stagedstate yellow
end
if not set -q __fish_git_prompt_color_invalidstate
set -g __fish_git_prompt_color_invalidstate red
end
if not set -q __fish_git_prompt_color_untrackedfiles
set -g __fish_git_prompt_color_untrackedfiles $fish_color_normal
end
if not set -q __fish_git_prompt_color_cleanstate
set -g __fish_git_prompt_color_cleanstate green --bold
end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
set -l color_cwd
set -l prefix
set -l suffix
switch "$USER"
case root toor
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
else
set color_cwd $fish_color_cwd
end
set suffix '#'
case '*'
set color_cwd $fish_color_cwd
set suffix '$'
end
# PWD
set_color $color_cwd
echo -n (prompt_pwd)
set_color normal
printf '%s ' (__fish_vcs_prompt)
if not test $last_status -eq 0
set_color $fish_color_error
echo -n "[$last_status] "
set_color normal
end
if set -q SSH_TTY
set -g fish_color_host brred
end
echo -n "$suffix "
end

View File

@@ -0,0 +1,17 @@
function _rb_prompt
# rbenv local > /dev/null 2>&1 && echo " ["(rbenv local | awk '{print $1}')"]"
echo ''
end
function fish_right_prompt
set -l normal (set_color normal)
set -l cyan (set_color cyan)
set -l grey (set_color 3C3836)
set -l date (date "+%H:%M")
set -l date "$grey$date$normal"
set -l ruby_version $cyan(_rb_prompt)
set -l ruby_version "$ruby_version$normal"
echo -s $date$ruby_version
end

View File

@@ -0,0 +1,430 @@
set -g fisher_version 3.2.9
function fisher -a cmd -d "fish package manager"
set -q XDG_CACHE_HOME; or set XDG_CACHE_HOME ~/.cache
set -q XDG_CONFIG_HOME; or set XDG_CONFIG_HOME ~/.config
set -g fish_config $XDG_CONFIG_HOME/fish
set -g fisher_cache $XDG_CACHE_HOME/fisher
set -g fisher_config $XDG_CONFIG_HOME/fisher
set -q fisher_path; or set -g fisher_path $fish_config
for path in {$fish_config,$fisher_path}/{functions,completions,conf.d} $fisher_cache
if test ! -d $path
command mkdir -p $path
end
end
if test ! -e $fisher_path/completions/fisher.fish
echo "fisher complete" >$fisher_path/completions/fisher.fish
_fisher_complete
end
if test -e $fisher_path/conf.d/fisher.fish
switch "$version"
case \*-\*
command rm -f $fisher_path/conf.d/fisher.fish
case 2\*
case \*
command rm -f $fisher_path/conf.d/fisher.fish
end
else
switch "$version"
case \*-\*
case 2\*
echo "fisher copy-user-key-bindings" >$fisher_path/conf.d/fisher.fish
end
end
switch "$cmd"
case {,self-}complete
_fisher_complete
case copy-user-key-bindings
_fisher_copy_user_key_bindings
case ls
set -e argv[1]
if test -s "$fisher_path/fishfile"
set -l file (_fisher_fmt <$fisher_path/fishfile | _fisher_parse -R | command sed "s|@.*||")
_fisher_ls | _fisher_fmt | command awk -v FILE="$file" "
BEGIN { for (n = split(FILE, f); ++i <= n;) file[f[i]] } \$0 in file && /$argv[1]/
" | command sed "s|^$HOME|~|"
end
case self-update
_fisher_self_update (status -f)
case self-uninstall
_fisher_self_uninstall
case {,-}-v{ersion,}
echo "fisher version $fisher_version" (status -f | command sed "s|^$HOME|~|")
case {,-}-h{elp,}
_fisher_help
case ""
_fisher_commit --
case add rm
if not isatty
while read -l arg
set argv $argv $arg
end
end
if test (count $argv) = 1
echo "fisher: invalid number of arguments" >&2
_fisher_help >&2
return 1
end
_fisher_commit $argv
case \*
echo "fisher: unknown flag or command \"$cmd\"" >&2
_fisher_help >&2
return 1
end
end
function _fisher_complete
complete -ec fisher
complete -xc fisher -n __fish_use_subcommand -a add -d "Add packages"
complete -xc fisher -n __fish_use_subcommand -a rm -d "Remove packages"
complete -xc fisher -n __fish_use_subcommand -a ls -d "List installed packages matching REGEX"
complete -xc fisher -n __fish_use_subcommand -a --help -d "Show usage help"
complete -xc fisher -n __fish_use_subcommand -a --version -d "$fisher_version"
complete -xc fisher -n __fish_use_subcommand -a self-update -d "Update to the latest version"
for pkg in (fisher ls)
complete -xc fisher -n "__fish_seen_subcommand_from rm" -a $pkg
end
end
function _fisher_copy_user_key_bindings
if functions -q fish_user_key_bindings
functions -c fish_user_key_bindings fish_user_key_bindings_copy
end
function fish_user_key_bindings
for file in $fisher_path/conf.d/*_key_bindings.fish
source $file >/dev/null 2>/dev/null
end
if functions -q fish_user_key_bindings_copy
fish_user_key_bindings_copy
end
end
end
function _fisher_ls
for pkg in $fisher_config/*/*/*
command readlink $pkg; or echo $pkg
end
end
function _fisher_fmt
command sed "s|^[[:space:]]*||;s|^$fisher_config/||;s|^~|$HOME|;s|^\.\/*|$PWD/|;s|^https*:/*||;s|^github\.com/||;s|/*\$||"
end
function _fisher_help
echo "usage: fisher add <package...> Add packages"
echo " fisher rm <package...> Remove packages"
echo " fisher Update all packages"
echo " fisher ls [<regex>] List installed packages matching <regex>"
echo " fisher --help Show this help"
echo " fisher --version Show the current version"
echo " fisher self-update Update to the latest version"
echo " fisher self-uninstall Uninstall from your system"
echo "examples:"
echo " fisher add jethrokuan/z rafaelrinaldi/pure"
echo " fisher add gitlab.com/foo/bar@v2"
echo " fisher add ~/path/to/local/pkg"
echo " fisher add <file"
echo " fisher rm rafaelrinaldi/pure"
echo " fisher ls | fisher rm"
echo " fisher ls fish-\*"
end
function _fisher_self_update -a file
set -l url "https://raw.githubusercontent.com/jorgebucaran/fisher/master/fisher.fish"
echo "fetching $url" >&2
command curl -s "$url?nocache" >$file.
set -l next_version (command awk '{ print $4 } { exit }' <$file.)
switch "$next_version"
case "" $fisher_version
command rm -f $file.
if test -z "$next_version"
echo "fisher: cannot update fisher -- are you offline?" >&2
return 1
end
echo "fisher is already up-to-date" >&2
case \*
echo "linking $file" | command sed "s|$HOME|~|" >&2
command mv -f $file. $file
source $file
echo "updated to fisher $fisher_version -- hooray!" >&2
_fisher_complete
end
end
function _fisher_self_uninstall
for pkg in (_fisher_ls)
_fisher_rm $pkg
end
for file in $fisher_cache $fisher_config $fisher_path/{functions,completions,conf.d}/fisher.fish $fisher_path/fishfile
echo "removing $file"
command rm -Rf $file 2>/dev/null
end | command sed "s|$HOME|~|" >&2
for name in (set -n | command awk '/^fisher_/')
set -e "$name"
end
functions -e (functions -a | command awk '/^_fisher/') fisher
complete -c fisher --erase
end
function _fisher_commit -a cmd
set -e argv[1]
set -l elapsed (_fisher_now)
set -l fishfile $fisher_path/fishfile
if test ! -e "$fishfile"
command touch $fishfile
echo "created new fishfile in $fishfile" | command sed "s|$HOME|~|" >&2
end
set -l old_pkgs (_fisher_ls | _fisher_fmt)
for pkg in (_fisher_ls)
_fisher_rm $pkg
end
command rm -Rf $fisher_config
command mkdir -p $fisher_config
set -l next_pkgs (_fisher_fmt <$fishfile | _fisher_parse -R $cmd (printf "%s\n" $argv | _fisher_fmt))
set -l actual_pkgs (_fisher_fetch $next_pkgs)
set -l updated_pkgs
for pkg in $old_pkgs
if contains -- $pkg $actual_pkgs
set updated_pkgs $updated_pkgs $pkg
end
end
if test -z "$actual_pkgs$updated_pkgs$old_pkgs$next_pkgs"
echo "fisher: nothing to commit -- try adding some packages" >&2
return 1
end
set -l out_pkgs
if test "$cmd" = "rm"
set out_pkgs $next_pkgs
else
for pkg in $next_pkgs
if contains -- (echo $pkg | command sed "s|@.*||") $actual_pkgs
set out_pkgs $out_pkgs $pkg
end
end
end
printf "%s\n" (_fisher_fmt <$fishfile | _fisher_parse -W $cmd $out_pkgs | command sed "s|^$HOME|~|") >$fishfile
_fisher_complete
command awk -v A=(count $actual_pkgs) -v U=(count $updated_pkgs) -v O=(count $old_pkgs) -v E=(_fisher_now $elapsed) '
BEGIN {
res = fmt("removed", O - U, fmt("updated", U, fmt("added", A - U)))
printf((res ? res : "done") " in %.2fs\n", E / 1000)
}
function fmt(action, n, s) {
return n ? (s ? s ", " : s) action " " n " package" (n > 1 ? "s" : "") : s
}
' >&2
end
function _fisher_parse -a mode cmd
set -e argv[1..2]
command awk -v FS="[[:space:]]*#+" -v MODE="$mode" -v CMD="$cmd" -v ARGSTR="$argv" '
BEGIN {
for (n = split(ARGSTR, a, " "); i++ < n;) pkgs[getkey(a[i])] = a[i]
}
!NF { next } { k = getkey($1) }
MODE == "-R" && !(k in pkgs) && $0 = $1
MODE == "-W" && (/^#/ || k in pkgs || CMD != "rm") { print pkgs[k] (sub($1, "") ? $0 : "") }
MODE == "-W" || CMD == "rm" { delete pkgs[k] }
END {
for (k in pkgs) {
if (CMD != "rm" || MODE == "-W") print pkgs[k]
else print "fisher: cannot remove \""k"\" -- package is not in fishfile" > "/dev/stderr"
}
}
function getkey(s, a) {
return (split(s, a, /@+|:/) > 2) ? a[2]"/"a[1]"/"a[3] : a[1]
}
'
end
function _fisher_fetch
set -l pkg_jobs
set -l out_pkgs
set -l next_pkgs
set -l local_pkgs
set -q fisher_user_api_token; and set -l curl_opts -u $fisher_user_api_token
for pkg in $argv
switch $pkg
case \~\* /\*
set -l path (echo "$pkg" | command sed "s|^~|$HOME|")
if test -e "$path"
set local_pkgs $local_pkgs $path
else
echo "fisher: cannot add \"$pkg\" -- is this a valid file?" >&2
end
continue
end
command awk -v PKG="$pkg" -v FS=/ '
BEGIN {
if (split(PKG, tmp, /@+|:/) > 2) {
if (tmp[4]) sub("@"tmp[4], "", PKG)
print PKG "\t" tmp[2]"/"tmp[1]"/"tmp[3] "\t" (tmp[4] ? tmp[4] : "master")
} else {
pkg = split(PKG, _, "/") <= 2 ? "github.com/"tmp[1] : tmp[1]
tag = tmp[2] ? tmp[2] : "master"
print (\
pkg ~ /^github/ ? "https://codeload."pkg"/tar.gz/"tag : \
pkg ~ /^gitlab/ ? "https://"pkg"/-/archive/"tag"/"tmp[split(pkg, tmp, "/")]"-"tag".tar.gz" : \
pkg ~ /^bitbucket/ ? "https://"pkg"/get/"tag".tar.gz" : pkg \
) "\t" pkg
}
}
' | read -l url pkg branch
if test ! -d "$fisher_config/$pkg"
fish -c "
echo fetching $url >&2
command mkdir -p $fisher_config/$pkg $fisher_cache/(command dirname $pkg)
if test ! -z \"$branch\"
command git clone $url $fisher_config/$pkg --branch $branch --depth 1 2>/dev/null
or echo fisher: cannot clone \"$url\" -- is this a valid url\? >&2
else if command curl $curl_opts -Ss -w \"\" $url 2>&1 | command tar -xzf- -C $fisher_config/$pkg 2>/dev/null
command rm -Rf $fisher_cache/$pkg
command mv -f $fisher_config/$pkg/* $fisher_cache/$pkg
command rm -Rf $fisher_config/$pkg
command cp -Rf {$fisher_cache,$fisher_config}/$pkg
else if test -d \"$fisher_cache/$pkg\"
echo fisher: cannot connect to server -- looking in \"$fisher_cache/$pkg\" | command sed 's|$HOME|~|' >&2
command cp -Rf $fisher_cache/$pkg $fisher_config/$pkg/..
else
command rm -Rf $fisher_config/$pkg
echo fisher: cannot add \"$pkg\" -- is this a valid package\? >&2
end
" >/dev/null &
set pkg_jobs $pkg_jobs (_fisher_jobs --last)
set next_pkgs $next_pkgs "$fisher_config/$pkg"
end
end
if set -q pkg_jobs[1]
while for job in $pkg_jobs
contains -- $job (_fisher_jobs); and break
end
end
for pkg in $next_pkgs
if test -d "$pkg"
set out_pkgs $out_pkgs $pkg
_fisher_add $pkg
end
end
end
set -l local_prefix $fisher_config/local/$USER
if test ! -d "$local_prefix"
command mkdir -p $local_prefix
end
for pkg in $local_pkgs
set -l target $local_prefix/(command basename $pkg)
if test ! -L "$target"
command ln -sf $pkg $target
set out_pkgs $out_pkgs $pkg
_fisher_add $pkg --link
end
end
if set -q out_pkgs[1]
_fisher_fetch (
for pkg in $out_pkgs
if test -s "$pkg/fishfile"
_fisher_fmt <$pkg/fishfile | _fisher_parse -R
end
end)
printf "%s\n" $out_pkgs | _fisher_fmt
end
end
function _fisher_add -a pkg opts
for src in $pkg/{functions,completions,conf.d}/**.* $pkg/*.fish
set -l target (command basename $src)
switch $src
case $pkg/conf.d\*
set target $fisher_path/conf.d/$target
case $pkg/completions\*
set target $fisher_path/completions/$target
case $pkg/{functions,}\*
switch $target
case uninstall.fish
continue
case {init,key_bindings}.fish
set target $fisher_path/conf.d/(command basename $pkg)\_$target
case \*
set target $fisher_path/functions/$target
end
end
echo "linking $target" | command sed "s|$HOME|~|" >&2
if set -q opts[1]
command ln -sf $src $target
else
command cp -f $src $target
end
switch $target
case \*.fish
source $target >/dev/null 2>/dev/null
end
end
end
function _fisher_rm -a pkg
for src in $pkg/{conf.d,completions,functions}/**.* $pkg/*.fish
set -l target (command basename $src)
set -l filename (command basename $target .fish)
switch $src
case $pkg/conf.d\*
test "$filename.fish" = "$target"; and emit "$filename"_uninstall
set target conf.d/$target
case $pkg/completions\*
test "$filename.fish" = "$target"; and complete -ec $filename
set target completions/$target
case $pkg/{,functions}\*
test "$filename.fish" = "$target"; and functions -e $filename
switch $target
case uninstall.fish
source $src
continue
case {init,key_bindings}.fish
set target conf.d/(command basename $pkg)\_$target
case \*
set target functions/$target
end
end
command rm -f $fisher_path/$target
end
if not functions -q fish_prompt
source "$__fish_datadir$__fish_data_dir/functions/fish_prompt.fish"
end
end
function _fisher_jobs
jobs $argv | command awk '/^[0-9]+\t/ { print $1 }'
end
function _fisher_now -a elapsed
switch (command uname)
case Darwin \*BSD
command perl -MTime::HiRes -e 'printf("%.0f\n", (Time::HiRes::time() * 1000) - $ARGV[0])' $elapsed
case \*
math (command date "+%s%3N") - "0$elapsed"
end
end

View File

@@ -0,0 +1,9 @@
function fuck -d "Correct your previous console command"
set -l fucked_up_command $history[1]
env TF_SHELL=fish TF_ALIAS=fuck PYTHONIOENCODING=utf-8 thefuck $fucked_up_command | read -l unfucked_command
if [ "$unfucked_command" != "" ]
eval $unfucked_command
builtin history delete --exact --case-sensitive -- $fucked_up_command
builtin history merge ^ /dev/null
end
end

View File

@@ -0,0 +1,57 @@
# https://github.com/oguzbilgic/dotfiles/blob/master/config/fish/functions/gh.fish
# Save this as ./config/fish/functions/gh.fish
# Prints the remote url
# Example: git@github.com:oguzbilgic/dotfiles.git
function origin
echo (git remote get-url origin)
end
# Prints the origin and remote
# Example: oguzbilgic/dotfiles
function org_repo
echo (origin | python -c "import sys; url = sys.stdin.readlines()[0].strip(); print url.split(':')[1][:-4]")
end
# Prints the current branch name
# Example: master
function branch
echo (git rev-parse --abbrev-ref HEAD)
end
# Prints the current branch name
# Example: 2cc1aad3e961ca57f6d96498d5fe70a31d9f17f0
function commit
echo (git rev-parse HEAD)
end
# Easily open Github from your command line
#
# Commands:
# gh opens the current branch
# gh [file] opens the file for the current branch (ie. gh README.md)
# gh issues opens the issues page
# gh pulls opens the pull requests page
# gh actions opens the actions page
# gh compare opens the compare for the current branch
# gh commit opens the last commit of the current branch
# gh commits opens the commits page for the current branch
function gh
if test (count $argv) -lt 1
open "https://github.com/"(org_repo)"/tree/"(branch)
else if test -f $argv[1]
open "https://github.com/"(org_repo)"/blob/"(commit)"/"(echo $argv[1])
else if test $argv[1] = "issues"
open "https://github.com/"(org_repo)"/issues"
else if test $argv[1] = "pulls"
open "https://github.com/"(org_repo)"/issues"
else if test $argv[1] = "actions"
open "https://github.com/"(org_repo)"/issues"
else if test $argv[1] = "compare"
open "https://github.com/"(org_repo)"/compare/"(branch)
else if test $argv[1] = "commits"
open "https://github.com/"(org_repo)"/commits/"(branch)
else if test $argv[1] = "commit"
open "https://github.com/"(org_repo)"/commit/"(commit)
end
end

View File

@@ -0,0 +1,3 @@
function hors
command hors -c "$argv"
end

View File

@@ -0,0 +1,51 @@
set -g spark_version 1.0.0
complete -xc spark -n __fish_use_subcommand -a --help -d "Show usage help"
complete -xc spark -n __fish_use_subcommand -a --version -d "$spark_version"
complete -xc spark -n __fish_use_subcommand -a --min -d "Minimum range value"
complete -xc spark -n __fish_use_subcommand -a --max -d "Maximum range value"
function spark -d "sparkline generator"
if isatty
switch "$argv"
case {,-}-v{ersion,}
echo "spark version $spark_version"
case {,-}-h{elp,}
echo "usage: spark [--min=<n> --max=<n>] <numbers...> Draw sparklines"
echo "examples:"
echo " spark 1 2 3 4"
echo " seq 100 | sort -R | spark"
echo " awk \\\$0=length spark.fish | spark"
case \*
echo $argv | spark $argv
end
return
end
command awk -v FS="[[:space:],]*" -v argv="$argv" '
BEGIN {
min = match(argv, /--min=[0-9]+/) ? substr(argv, RSTART + 6, RLENGTH - 6) + 0 : ""
max = match(argv, /--max=[0-9]+/) ? substr(argv, RSTART + 6, RLENGTH - 6) + 0 : ""
}
{
for (i = j = 1; i <= NF; i++) {
if ($i ~ /^--/) continue
if ($i !~ /^-?[0-9]/) data[count + j++] = ""
else {
v = data[count + j++] = int($i)
if (max == "" && min == "") max = min = v
if (max < v) max = v
if (min > v ) min = v
}
}
count += j - 1
}
END {
n = split(min == max && max ? "▅ ▅" : "▁ ▂ ▃ ▄ ▅ ▆ ▇ █", blocks, " ")
scale = (scale = int(256 * (max - min) / (n - 1))) ? scale : 1
for (i = 1; i <= count; i++)
out = out (data[i] == "" ? " " : blocks[idx = int(256 * (data[i] - min) / scale) + 1])
print out
}
'
end

View File

@@ -0,0 +1,3 @@
function su
command su --shell=/bin/fish $argv
end

View File

@@ -0,0 +1,3 @@
function sudosu
command sudo su --shell=/bin/fish -
end

View File

@@ -0,0 +1,3 @@
function time
command time --portability $argv
end