Switch fish to batman theme #fishfile

This commit is contained in:
Colin Powell
2019-02-15 09:26:26 -05:00
parent be745cc8f5
commit 6146684138
40 changed files with 89 additions and 1459 deletions

View File

@ -1 +0,0 @@
complete -c a -a "(__fasd_print_completion -a)" -f

View File

@ -1 +0,0 @@
complete -c d -a "(__fasd_print_completion -d)" -f

View File

@ -1 +0,0 @@
complete -c f -a "(__fasd_print_completion -f)" -f

View File

@ -1,18 +0,0 @@
# suggest paths
complete -c fasd -a "(__fasd_print_completion)" -f
# suggest args
complete -c fasd -s s -d "List all paths and scores" -f
complete -c fasd -s l -d "List paths without scores" -f
complete -c fasd -s i -d "Interactive mode" -f
complete -c fasd -s e -a (echo subl atom) -d "Set command to execute on the result file" -f
complete -c fasd -s b -a (echo spotlight viminfo recently-used current) -d "Only use given backend" -f
complete -c fasd -s B -a (echo spotlight viminfo recently-used current) -d "Add additional backend" -f
complete -c fasd -s a -d "Match files and directories" -f
complete -c fasd -s d -d "Match directories only" -f
complete -c fasd -s f -d "Match files only" -f
complete -c fasd -s r -d "Match by rank only" -f
complete -c fasd -s t -d "Match by recent access only" -f
complete -c fasd -s R -d "Reverse listing order" -f
complete -c fasd -s h -d "Show a brief help message" -f
# complete -c fasd -s [0-9] "Select the nth entry"

View File

@ -1 +0,0 @@
complete -c s -a "(__fasd_print_completion)" -f

View File

@ -1 +0,0 @@
complete -c sd -a "(__fasd_print_completion -d)" -f

View File

@ -1 +0,0 @@
complete -c sf -a "(__fasd_print_completion -f)" -f

View File

@ -1 +0,0 @@
complete -c z -a "(__fasd_print_completion -d)" -f

View File

@ -1 +0,0 @@
complete -c zz -a "(__fasd_print_completion -d)" -f

View File

@ -1,3 +0,0 @@
# support oldschool autojump user
alias j z
alias jj zz

View File

@ -5,9 +5,10 @@ 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
set -l _vars (set | command grep -E "^FZF.*\$" | command awk '{print $1;}')
for var in $_vars
echo $var
eval (set -e $var)
end
# 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

@ -34,11 +34,16 @@ 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
set -l _bindings (bind -a | sed -En "s/(')?__fzf.*\$//p" | sed 's/bind/bind -e/')
for binding in $_bindings
eval $binding
end
# 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

View File

@ -1,44 +0,0 @@
if test -z "$Z_DATA"
if test -z "$XDG_DATA_HOME"
set -U Z_DATA_DIR "$HOME/.local/share/z"
else
set -U Z_DATA_DIR "$XDG_DATA_HOME/z"
end
set -U Z_DATA "$Z_DATA_DIR/data"
end
if test ! -e "$Z_DATA"
if test ! -e "$Z_DATA_DIR"
mkdir -p -m 700 "$Z_DATA_DIR"
end
touch "$Z_DATA"
end
if test -z "$Z_CMD"
set -U Z_CMD "z"
end
set -U ZO_CMD "$Z_CMD"o
if test ! -z $Z_CMD
function $Z_CMD -d "jump around"
__z $argv
end
end
if test ! -z $ZO_CMD
function $ZO_CMD -d "open target dir"
__z -d $argv
end
end
if not set -q Z_EXCLUDE
set -U Z_EXCLUDE $HOME
end
# Setup completions once first
__z_complete
function __z_on_variable_pwd --on-variable PWD
__z_add
end

View File

@ -7,11 +7,7 @@ SETUVAR FZF_PREVIEW_FILE_CMD:head\x20\x2dn\x2010
SETUVAR FZF_TMUX_HEIGHT:40\x25
SETUVAR --export TERM:screen\x2d256color
SETUVAR THEME_EDEN_PROMPT_CHAR:\u00bb
SETUVAR ZO_CMD:zo
SETUVAR Z_CMD:z
SETUVAR Z_DATA:/Users/colinpowell/\x2elocal/share/z/data
SETUVAR Z_DATA_DIR:/Users/colinpowell/\x2elocal/share/z
SETUVAR Z_EXCLUDE:/Users/colinpowell
SETUVAR __fish_init_2_39_8:\x1d
SETUVAR __fish_init_2_3_0:\x1d
SETUVAR __fish_init_3_x:\x1d

View File

@ -1,7 +1,7 @@
jethrokuan/fzf
2m/fish-gpg-tty
asdf-vm/asdf
edc/bass
jethrokuan/fzf
asdf-vm/asdf
2m/fish-gpg-tty
oh-my-fish/plugin-direnv
oh-my-fish/theme-agnoster
oh-my-fish/theme-bobthefish
oh-my-fish/theme-batman

View File

@ -0,0 +1 @@
function __batman_color_dim; set_color 666; end

View File

@ -0,0 +1 @@
function __batman_color_fst; set_color -o fa0; end

View File

@ -0,0 +1 @@
function __batman_color_off; set_color normal; end

View File

@ -0,0 +1 @@
function __batman_color_snd; set_color -o 36f; end

View File

@ -0,0 +1 @@
function __batman_color_trd; set_color -o f06; end

View File

@ -1,5 +0,0 @@
# suggest paths for current args as completion
function __fasd_print_completion
set cmd (commandline -po)
test (count $cmd) -ge 2; and fasd $argv $cmd[2..-1] -l
end

View File

@ -11,18 +11,20 @@ function __fzf_complete_preview -d 'generate preview for completion widget.
echo $argv[1]
end
set -l path (string replace "~" $HOME $argv[1])
# list directories on preview
if test -d "$argv[1]"
eval $FZF_PREVIEW_DIR_CMD (string escape $argv[1])
if test -d "$path"
eval $FZF_PREVIEW_DIR_CMD (string escape $path)
end
# show ten lines of non-binary files preview
if test -f "$argv[1]"; and grep -qI . "$argv[1]"
eval $FZF_PREVIEW_FILE_CMD (string escape $argv[1])
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 "$argv[1]" 2>/dev/null; and type -a "$argv[1]"
type -q "$path" 2>/dev/null; and type -a "$path"
# show aditional data
echo $argv[2]

View File

@ -1,151 +0,0 @@
function __z -d "Jump to a recent directory."
function __print_help -d "Print z help."
printf "Usage: $Z_CMD [-celrth] regex1 regex2...\n\n"
printf " -c --clean Removes directories that no longer exist from $Z_DATA\n"
printf " -d --dir Opens matching directory using system file manager.\n"
printf " -e --echo Prints best match, no cd\n"
printf " -l --list List matches and scores, no cd\n"
printf " -p --purge Delete all entries from $Z_DATA\n"
printf " -r --rank Search by rank\n"
printf " -t --recent Search by recency\n"
printf " -x --delete Removes the current directory from $Z_DATA\n"
printf " -h --help Print this help\n\n"
if type -q fisher
printf "Run `fisher help z` for more information.\n"
end
end
set -l options "h/help" "c/clean" "e/echo" "l/list" "p/purge" "r/rank" "t/recent" "d/directory" "x/delete"
argparse $options -- $argv
if set -q _flag_help
__print_help
return 0
else if set -q _flag_clean
__z_clean
printf "%s cleaned!\n" $Z_DATA
return 0
else if set -q _flag_purge
echo > $Z_DATA
printf "%s purged!\n" $Z_DATA
return 0
else if set -q _flag_delete
sed -i -e "\:^$PWD|.*:d" $Z_DATA
return 0
end
set -l typ
if set -q _flag_rank
set typ "rank"
else if set -q _flag_recent
set typ "recent"
end
set -l z_script '
function frecent(rank, time) {
dx = t-time
if( dx < 3600 ) return rank*4
if( dx < 86400 ) return rank*2
if( dx < 604800 ) return rank/2
return rank/4
}
function output(matches, best_match, common) {
# list or return the desired directory
if( list ) {
cmd = "sort -nr"
for( x in matches ) {
if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd
}
}
if( common ) {
printf "%-10s %s\n", "common:", common > "/dev/stderr"
}
} else {
if( common ) best_match = common
print best_match
}
}
function common(matches) {
# find the common root of a list of matches, if it exists
for( x in matches ) {
if( matches[x] && (!short || length(x) < length(short)) ) {
short = x
}
}
if( short == "/" ) return
for( x in matches ) if( matches[x] && index(x, short) != 1 ) {
return
}
return short
}
BEGIN {
gsub(" ", ".*", q)
hi_rank = ihi_rank = -9999999999
}
{
if( typ == "rank" ) {
rank = $2
} else if( typ == "recent" ) {
rank = $3 - t
} else rank = frecent($2, $3)
if( $1 ~ q ) {
matches[$1] = rank
} else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank
if( matches[$1] && matches[$1] > hi_rank ) {
best_match = $1
hi_rank = matches[$1]
} else if( imatches[$1] && imatches[$1] > ihi_rank ) {
ibest_match = $1
ihi_rank = imatches[$1]
}
}
END {
# prefer case sensitive
if( best_match ) {
output(matches, best_match, common(matches))
} else if( ibest_match ) {
output(imatches, ibest_match, common(imatches))
}
}
'
if set -q _flag_list
# Handle list separately as it can print common path information to stderr
# which cannot be captured from a subcommand.
command awk -v t=(date +%s) -v list="list" -v typ="$typ" -v q="$argv" -F "|" $z_script "$Z_DATA"
else
set target (command awk -v t=(date +%s) -v typ="$typ" -v q="$argv" -F "|" $z_script "$Z_DATA")
if test "$status" -gt 0
return
end
if test -z "$target"
printf "'%s' did not match any results\n" "$argv"
return 1
end
if set -q _flag_list
echo "$target" | tr ";" "\n" | sort -nr
return 0
end
if set -q _flag_echo
printf "%s\n" "$target"
else if set -q _flag_directory
type -q xdg-open;and xdg-open "$target"; and return $status;
type -q open;and open "$target"; and return $status;
echo "Not sure how to open file manager"; and return 1;
else
pushd "$target"
end
end
end

View File

@ -1,48 +0,0 @@
function __z_add -d "Add PATH to .z file"
for i in $Z_EXCLUDE
if contains -- $PWD $i
return 0 #Path excluded
end
end
set -l tmpfile (mktemp $Z_DATA.XXXXXX)
if test -f $tmpfile
command awk -v path="$PWD" -v now=(date +%s) -F "|" '
BEGIN {
rank[path] = 1
time[path] = now
}
$2 >= 1 {
if( $1 == path ) {
rank[$1] = $2 + 1
time[$1] = now
}
else {
rank[$1] = $2
time[$1] = $3
}
count += $2
}
END {
if( count > 1000 ) {
for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging
}
else for( i in rank ) print i "|" rank[i] "|" time[i]
}
' $Z_DATA 2>/dev/null >$tmpfile
if test ! -z "$Z_OWNER"
chown $Z_OWNER:(id -ng $Z_OWNER) $tmpfile
end
#
# Don't use redirection here as it can lead to a race condition where $Z_DATA is clobbered.
# Note: There is a still a possible race condition where an old version of $Z_DATA is
# read by one instance of Fish before another instance of Fish writes its copy.
#
command mv $tmpfile $Z_DATA
or command rm $tmpfile
end
__z_complete
end

View File

@ -1,10 +0,0 @@
function __z_clean -d "Clean up .z file to remove paths no longer valid"
set -l tmpfile (mktemp $Z_DATA.XXXXXX)
if test -f $tmpfile
command awk -F "|" 'system("test -d \"" $1 "\"") == 0 { print $0 }' $Z_DATA > $tmpfile
command mv -f $tmpfile $Z_DATA
end
__z_complete
end

View File

@ -1,14 +0,0 @@
function __z_complete -d "add completions"
set -l __z_marks (string replace -r '\|.*' '' < $Z_DATA | string escape)
complete -c $Z_CMD -a "$__z_marks" -f
complete -c $ZO_CMD -a "$__z_marks" -f
complete -c $Z_CMD -s c -l clean -d "Cleans out $Z_DATA"
complete -c $Z_CMD -s e -l echo -d "Prints best match, no cd"
complete -c $Z_CMD -s l -l list -d "List matches, no cd"
complete -c $Z_CMD -s p -l purge -d "Purges $Z_DATA"
complete -c $Z_CMD -s r -l rank -d "Searches by rank, cd"
complete -c $Z_CMD -s t -l recent -d "Searches by recency, cd"
complete -c $Z_CMD -s h -l help -d "Print help"
end

View File

@ -1,3 +0,0 @@
function a -d "Match files and directories"
fasd -a $argv
end

View File

@ -1,12 +1,12 @@
#!/usr/bin/env fish
set -l asdf_dir (dirname (status -f))
set -x ASDF_DIR (dirname (status -f))
set -l asdf_data_dir (
if test -n "$ASDF_DATA_DIR"; echo $ASDF_DATA_DIR;
else; echo $HOME/.asdf; end)
# Add asdf to PATH
set -l asdf_bin_dirs $asdf_dir/bin $asdf_dir/shims $asdf_data_dir/shims
set -l asdf_bin_dirs $ASDF_DIR/bin $ASDF_DIR/shims $asdf_data_dir/shims
for x in $asdf_bin_dirs
if begin not contains $x $fish_user_paths; and test -d $x; end

View File

@ -1,3 +0,0 @@
function d -d "Match directories only"
fasd -d $argv
end

View File

@ -1,3 +0,0 @@
function f -d "Match files only"
fasd -f $argv
end

View File

@ -1,9 +0,0 @@
function fasd_cd -d "fasd builtin cd"
if test (count $argv) -le 1
command fasd "$argv"
else
set -l ret (command fasd -e 'printf %s' $argv)
test -z "$ret"; and return
test -d "$ret"; and cd "$ret"; or printf "%s\n" $ret
end
end

View File

@ -1,6 +1,3 @@
function fish_greeting -d "What's up, fish?"
set_color $fish_color_autosuggestion
uname -nmsr
uptime
set_color normal
function fish_greeting
echo (__batman_color_dim)(uname -mnprs)(__batman_color_off)
end

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +1,43 @@
# You can override some default right prompt options in your config.fish:
# set -g theme_date_format "+%a %H:%M"
function __bobthefish_cmd_duration -S -d 'Show command duration'
[ "$theme_display_cmd_duration" = "no" ]
and return
[ -z "$CMD_DURATION" -o "$CMD_DURATION" -lt 100 ]
and return
if [ "$CMD_DURATION" -lt 5000 ]
echo -ns $CMD_DURATION 'ms'
else if [ "$CMD_DURATION" -lt 60000 ]
__bobthefish_pretty_ms $CMD_DURATION s
else if [ "$CMD_DURATION" -lt 3600000 ]
set_color $fish_color_error
__bobthefish_pretty_ms $CMD_DURATION m
else
set_color $fish_color_error
__bobthefish_pretty_ms $CMD_DURATION h
end
set_color $fish_color_normal
set_color $fish_color_autosuggestion
[ "$theme_display_date" = "no" ]
or echo -ns ' ' $__bobthefish_left_arrow_glyph
function git::is_stashed
command git rev-parse --verify --quiet refs/stash >/dev/null
end
function __bobthefish_pretty_ms -S -a ms interval -d 'Millisecond formatting for humans'
set -l interval_ms
set -l scale 1
switch $interval
case s
set interval_ms 1000
case m
set interval_ms 60000
case h
set interval_ms 3600000
set scale 2
end
switch $FISH_VERSION
# Fish 2.3 and lower doesn't know about the -s argument to math.
case 2.0.\* 2.1.\* 2.2.\* 2.3.\*
math "scale=$scale;$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
case \*
math -s$scale "$ms/$interval_ms" | string replace -r '\\.?0*$' $interval
end
function git::get_ahead_count
echo (command git log 2> /dev/null | grep '^commit' | wc -l | tr -d " ")
end
function __bobthefish_timestamp -S -d 'Show the current timestamp'
[ "$theme_display_date" = "no" ]
and return
set -q theme_date_format
or set -l theme_date_format "+%c"
echo -n ' '
date $theme_date_format
function git::branch_name
command git symbolic-ref --short HEAD
end
function fish_right_prompt -d 'bobthefish is all about the right prompt'
set -l __bobthefish_left_arrow_glyph \uE0B3
if [ "$theme_powerline_fonts" = "no" ]
set __bobthefish_left_arrow_glyph '<'
end
set_color $fish_color_autosuggestion
__bobthefish_cmd_duration
__bobthefish_timestamp
set_color normal
function git::is_touched
test -n (echo (command git status --porcelain))
end
function fish_right_prompt
set -l code $status
test $code -ne 0; and echo (__batman_color_dim)"("(__batman_color_trd)"$code"(__batman_color_dim)") "(__batman_color_off)
if test -n "$SSH_CONNECTION"
printf (__batman_color_trd)":"(__batman_color_dim)"$HOSTNAME "(__batman_color_off)
end
if git rev-parse 2> /dev/null
git::is_stashed; and echo (__batman_color_trd)"^"(__batman_color_off)
printf (__batman_color_snd)"("(begin
if git::is_touched
echo (__batman_color_trd)"*"(__batman_color_off)
else
echo ""
end
end)(__batman_color_fst)(git::branch_name)(__batman_color_snd)(begin
set -l count (git::get_ahead_count)
if test $count -eq 0
echo ""
else
echo (__batman_color_trd)"+"(__batman_color_fst)$count
end
end)(__batman_color_snd)") "(__batman_color_off)
end
printf (__batman_color_dim)(date +%H(__batman_color_fst):(__batman_color_dim)%M(__batman_color_fst):(__batman_color_dim)%S)(__batman_color_off)" "
end

View File

@ -1,34 +1,3 @@
# You can override some default title options in your config.fish:
# set -g theme_title_display_process no
# set -g theme_title_display_path no
# set -g theme_title_display_user yes
# set -g theme_title_use_abbreviated_path no
function __bobthefish_title_user -S -d 'Display actual user if different from $default_user'
if [ "$theme_title_display_user" = 'yes' ]
if [ "$USER" != "$default_user" -o -n "$SSH_CLIENT" ]
set -l IFS .
hostname | read -l hostname __
echo -ns (whoami) '@' $hostname ' '
end
end
end
function fish_title
__bobthefish_title_user
if [ "$theme_title_display_process" = 'yes' ]
echo $_
[ "$theme_title_display_path" != 'no' ]
and echo ' '
end
if [ "$theme_title_display_path" != 'no' ]
if [ "$theme_title_use_abbreviated_path" = 'no' ]
echo $PWD
else
prompt_pwd
end
end
end
echo "$PWD | $_" | sed "s|$HOME|~|g"
end

View File

@ -1,3 +0,0 @@
function s -d "Interactively select from all"
fasd -is $argv
end

View File

@ -1,3 +0,0 @@
function sd -d "Interactively select directory"
fasd -isd $argv
end

View File

@ -1,3 +0,0 @@
function sf -d "Interactively select file"
fasd -isf $argv
end

View File

@ -1,3 +0,0 @@
function z -d "Change directory to first match"
fasd_cd -d $argv
end

View File

@ -1,3 +0,0 @@
function zz -d "Change directory with interactive selection"
fasd_cd -id $argv
end