mirror of https://github.com/jorgebucaran/fisher
1.5.0
parent
aaf5654f06
commit
c5624a6832
@ -1,62 +0,0 @@
|
||||
SHELL:=/usr/bin/env bash -O nullglob
|
||||
|
||||
XDG_CONFIG_HOME ?= $$HOME/.config
|
||||
FISH_CONFIG := $(XDG_CONFIG_HOME)/fish/config.fish
|
||||
|
||||
FISHER_HOME := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
FISHER_CONFIG := $(XDG_CONFIG_HOME)/fisherman
|
||||
FISHER_CACHE := $(FISHER_CONFIG)/cache
|
||||
FISHER_FILE := $(FISHER_CONFIG)/fishfile
|
||||
|
||||
MAN := $(FISHER_HOME)/man
|
||||
MAN1 := $(wildcard $(MAN)/man1/*.md)
|
||||
DOCS := $(MAN1:%.md=%.1)
|
||||
|
||||
INDEX := $(FISHER_CACHE)/.index
|
||||
VERSION = `cat $(FISHER_HOME)/VERSION`
|
||||
|
||||
.PHONY: all test flush uninstall release
|
||||
|
||||
all: $(FISH_CONFIG) $(FISHER_CACHE) $(FISHER_FILE) $(DOCS)
|
||||
@echo "** Reload your shell and type 'fisher' to get started **"
|
||||
|
||||
test:
|
||||
fish -c "fishtape test/*.fish"
|
||||
|
||||
uninstall:
|
||||
sed -E '/set (fisher_home|fisher_config) /d;/source \$$fisher_home/d' \
|
||||
$(FISH_CONFIG) > $(FISH_CONFIG).tmp
|
||||
mv $(FISH_CONFIG).tmp $(FISH_CONFIG)
|
||||
$(call MSG,"Reload your shell to apply changes.")
|
||||
|
||||
release: $(FISHER_HOME)
|
||||
if [ "`git -C $^ status --short --porcelain | xargs`" = "M VERSION" ]; then\
|
||||
echo "`git -C $^ describe --abbrev=0 2>/dev/null || echo \*` -> $(VERSION)";\
|
||||
sed "s/latest-v.\..\..-00B9FF/latest-v$(VERSION)-00B9FF/" $^/README.md > $^/README.md.swap;\
|
||||
mv $^/README.md.swap $^/README.md;\
|
||||
git -C $^ add README.md;\
|
||||
git -C $^ add $^/VERSION;\
|
||||
git -C $^ commit --quiet -m $(VERSION);\
|
||||
git -C $^ tag $(VERSION) -m v$(VERSION) --force > /dev/null;\
|
||||
else\
|
||||
echo "Commit changes and update VERSION to tag a new release.";\
|
||||
fi
|
||||
|
||||
$(FISH_CONFIG):
|
||||
mkdir -p $(dir $@) && touch $@
|
||||
echo "set fisher_home $(FISHER_HOME)" | sed "s|/$$||;s|$$HOME|~|" > $@.fisher
|
||||
echo "set fisher_config $(FISHER_CONFIG)" | sed "s|$$HOME|~|" >> $@.fisher
|
||||
echo "source \$$fisher_home/config.fish" >> $@.fisher
|
||||
awk 'FNR==NR{ print; a[$$0]; next } !($$0 in a) || /^$$/' $@ $@.fisher > $@.tmp
|
||||
cat "$@.tmp" > $@ && rm $@.fisher
|
||||
|
||||
$(FISHER_CACHE):
|
||||
mkdir -p $@
|
||||
|
||||
$(FISHER_FILE):
|
||||
touch $@
|
||||
|
||||
%.1 : %.md
|
||||
-@if type ronn 2>/dev/null 1>&2; then \
|
||||
ronn --manual=fisherman --roff $? 1>&2 2> /dev/null;\
|
||||
fi;\
|
@ -0,0 +1,177 @@
|
||||
#!/usr/bin/env fish
|
||||
|
||||
function __fisher_format_source_safe
|
||||
if not command fish_indent $argv ^ /dev/null
|
||||
command fish_indent
|
||||
end
|
||||
end
|
||||
|
||||
function __fisher_home_humanize
|
||||
set -l tilde "$fisher_color_param~$fisher_color_close"
|
||||
sed "s|$HOME|$tilde|"
|
||||
end
|
||||
|
||||
function __fisher_run_commands -a message commands
|
||||
set -l fish_debug_copy $fish_debug
|
||||
set fish_debug
|
||||
|
||||
set -l tmp (mktemp -t fisherman.XXX)
|
||||
|
||||
fish -c "$commands" > /dev/null ^ $tmp &
|
||||
|
||||
while true
|
||||
for spinner in ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏
|
||||
set -l message (printf "%s\n" $message | __fisher_home_humanize)
|
||||
printf " $fisher_color_param$spinner$fisher_color_close $message\r"
|
||||
sleep 0.05
|
||||
end
|
||||
|
||||
set -l last_job (jobs -l | command awk -v FS=\t '
|
||||
/[0-9]+\t/{
|
||||
jobs[++job_count] = $1
|
||||
}
|
||||
|
||||
END {
|
||||
for (i = 1; i <= job_count; i++) {
|
||||
print(jobs[i])
|
||||
}
|
||||
|
||||
exit job_count == 0
|
||||
}
|
||||
')
|
||||
|
||||
if test -z "$last_job"
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if test -s $tmp
|
||||
cat $tmp
|
||||
|
||||
printf "\r $fisher_error_symbol\n\n"
|
||||
|
||||
printf "Sorry, but I couldn't install fisherman. Some things you can try:\n\n"
|
||||
|
||||
printf "%s\n" " $fisher_arrow_symbol Upgrade your Git version (^2.0)"
|
||||
printf "%s\n" " $fisher_arrow_symbol Upgrade your Fish version (^2.2.0)"
|
||||
printf "%s\n" " $fisher_arrow_symbol Make sure you can write to $fisher_home"
|
||||
printf "%s\n"
|
||||
printf "%s\n" "For more help visit "$fisher_color_uline"http://issues.fisherman.sh$fisher_color_close"
|
||||
|
||||
command rm -f $tmp
|
||||
|
||||
set fish_debug $fish_debug_copy
|
||||
|
||||
exit 1
|
||||
end
|
||||
|
||||
set fish_debug $fish_debug_copy
|
||||
|
||||
command rm -f $tmp
|
||||
|
||||
printf "\r $fisher_check_symbol \n"
|
||||
end
|
||||
|
||||
function __fisher_install_fisherman
|
||||
set xdg_home ~/.local/share
|
||||
set xdg_config ~/.config
|
||||
|
||||
if test ! -z "$XDG_DATA_HOME"
|
||||
set xdg_home "$XDG_DATA_HOME"
|
||||
end
|
||||
|
||||
if test ! -z "$XDG_CONFIG_HOME"
|
||||
set xdg_config "$XDG_CONFIG_HOME"
|
||||
end
|
||||
|
||||
set fisher_home "$xdg_home/fisherman"
|
||||
set fisher_config "$xdg_config/fisherman"
|
||||
set fish_config "$xdg_config/fish"
|
||||
|
||||
if test ! -z "$FISHER_HOME"
|
||||
set fisher_home "$FISHER_HOME"
|
||||
end
|
||||
|
||||
if test ! -z "$FISHER_CONFIG"
|
||||
set fisher_config "$FISHER_CONFIG"
|
||||
end
|
||||
|
||||
set -l config "$fish_config/config.fish"
|
||||
|
||||
if test -d $fisher_home
|
||||
printf " $fisher_error_symbol %s\n\n" "fisherman is already installed. To reinstall:"
|
||||
|
||||
printf " $fisher_arrow_symbol %s\n" "Remove $fisher_home" \
|
||||
| __fisher_home_humanize
|
||||
|
||||
if test -s $config
|
||||
printf " $fisher_arrow_symbol %s\n" "Remove this configuration from $fish_config" \
|
||||
| __fisher_home_humanize
|
||||
|
||||
printf "%s\n"
|
||||
set -l indent " "
|
||||
grep "fisher" $config | __fisher_format_source_safe --ansi | sed "s/^/ $indent /"
|
||||
|
||||
set_color normal
|
||||
end
|
||||
|
||||
printf "\n%s\n" "For more help visit "$fisher_color_uline"http://issues.fisherman.sh$fisher_color_close"
|
||||
|
||||
exit 1
|
||||
end
|
||||
|
||||
if test "$version" = 2.1.2
|
||||
printf "%s\n" (set_color ff0
|
||||
)" • Please upgrade to fish 2.2.0 for best results.$fisher_color_close"
|
||||
end
|
||||
|
||||
__fisher_run_commands \
|
||||
"Downloading fisherman to $fisher_home" \
|
||||
"git clone --quiet --depth 1 $fisher_remote_uri $fisher_home"
|
||||
|
||||
|
||||
set -l home ~
|
||||
|
||||
__fisher_run_commands \
|
||||
"Installing fisherman to $fisher_config" \
|
||||
"
|
||||
mkdir -p $fisher_config/{cache,functions,completions,conf.d,man}
|
||||
pushd $fish_config
|
||||
|
||||
echo 'set -g fisher_home $fisher_home' | sed 's|/\$||;s|$home|~|' >> fisherconf
|
||||
echo 'set -g fisher_config $fisher_config' | sed 's|$home|~|' >> fisherconf
|
||||
echo 'source \$fisher_home/config.fish' >> fisherconf
|
||||
|
||||
command awk 'FNR==NR{ print; a[\$0]; next } !(\$0 in a) || /^\$/' config.fish fisherconf > config.fish.tmp
|
||||
command mv config.fish.tmp config.fish
|
||||
command rm fisherconf
|
||||
|
||||
__fisher_index_update 0
|
||||
"
|
||||
|
||||
set -l gray (set_color aaa)
|
||||
|
||||
printf " $fisher_check_symbol ""$gray"" Done! Enter $fisherman""``fisher``""$fisher_color_close ""$gray""to get started\n\n"
|
||||
|
||||
printf " $fisher_arrow_symbol Plugins "$fisher_color_uline"http://plugins.fisherman.sh$fisher_color_close\n"
|
||||
printf " $fisher_arrow_symbol Community "$fisher_color_uline"http://slack.fisherman.sh$fisher_color_close\n"
|
||||
|
||||
if set -q CI
|
||||
exit
|
||||
end
|
||||
|
||||
exec fish < /dev/tty
|
||||
end
|
||||
|
||||
set -g fisher_color_param (set_color $fish_color_param)
|
||||
set -g fisher_color_uline (set_color -u)
|
||||
set -g fisher_color_error (set_color $fish_color_error)
|
||||
set -g fisher_color_close (set_color $fish_color_normal)
|
||||
|
||||
set -g fisher_check_symbol $fisher_color_param"✔"$fisher_color_close
|
||||
set -g fisher_error_symbol $fisher_color_error"✘"$fisher_color_close
|
||||
set -g fisher_arrow_symbol $fisher_color_param"▸"$fisher_color_close
|
||||
|
||||
set -g fisher_remote_uri "https://github.com/fisherman/fisherman"
|
||||
|
||||
__fisher_install_fisherman
|
Loading…
Reference in New Issue