This commit is contained in:
Aaron Gyes 2016-09-10 14:52:15 -07:00
commit b17ebb4551
50 changed files with 1536 additions and 507 deletions

21
.editorconfig Normal file
View File

@ -0,0 +1,21 @@
root = true
[*]
indent_size = 4
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{Makefile,*.in}]
indent_style = tab
[*.md]
trim_trailing_whitespace = false
[*.{sh,ac}]
indent_size = 2
[Dockerfile]
indent_size = 2

View File

@ -9,14 +9,13 @@
Talk about the the issue here.
## Reproduction steps
Hard to explain? Link to [a screen recording](https://asciinema.org)
1. Launch fish
1. step one
2. …
## Expected results
Fish should…
<!-- Hard to explain? Post a screen recording on asciinema.org then link it here -->
## Actual results
~ $ math 2 + 2
5
## Results
```console
~ $ math 2 + 2
5
```

View File

@ -2,6 +2,25 @@
## Significant changes
- The clipboard integration has been revamped with explicit bindings. OS X clipboard support provided for out of the box in addition to X11. (#3061)
- Vi-style bindings no longer build upon the default emacs-style bindings, instead they share some definitions (#3068).
- Fish will now try to set the locale when it doesn't inherit one by reading system configuration (#277)
- A number followed by a caret is no longer treated as a redirection (#1873)
## Notable fixes and improvements
- Completions that don't match the prefix will no longer expand to a common prefix (#3090)
- Suggestions will be offered more often, like after removing characters (#3069)
- The argument handling for the `history` function has been revamped (#3293, #3224, #3220, #3182)
- Improved argument handling for the `abbr` function (#2997, #3267)
- `history --merge` now correctly interleaves items in chronological order (#2312)
- `history` gained a new "--with-time" ("-t") option to show timestamps (#3175)
- The "-d" option to `fish_indent` was removed (#3191)
- A bug where fish would sometimes hang using 100% CPU in the C locale (#3214)
- Fish now uses the $TZ variable for its idea of localtime (#3181)
- Some performance improvments to the git prompt (#3294, 3083)
- Working completion after an escaped space character (#2447)
- Less output to fish's build (#3248)
- Some additions or fixes to the completions for `brew` (#3309), `git` (#3274, #3226, #3225, #3094, #3087, #3035, #3021, #2982, #3230), `aura` (#3297)
- New completions for perforce ("p4") (#3314)
---
# fish 2.3.1 (released July 3, 2016)

View File

@ -127,7 +127,7 @@ FISH_TESTS_OBJS := $(FISH_OBJS) obj/fish_tests.o
# (that is, are not themselves #included in other source files)
#
FISH_ALL_OBJS := $(sort $(FISH_OBJS) $(FISH_INDENT_OBJS) $(FISH_TESTS_OBJS) $(FISH_KEYREAD_OBJS) \
obj/fish.o)
obj/fish.o)
#
# Files containing user documentation
@ -205,39 +205,44 @@ else
share_man=
endif
T_COLORS:=$(shell tput colors || echo 0 2> /dev/null)
#
# Functions for status output
#
T_COLORS := $(shell tput colors 2> /dev/null)
T_GREEN := $(shell tput setaf 2 2> /dev/null)
T_YELLOWB := $(shell tput setaf 3 2> /dev/null; tput setab 0 2> /dev/null)
T_RED := $(shell tput setaf 1 2> /dev/null)
T_BOLD := $(shell tput bold 2> /dev/null)
# Dim: Doesn't work everywhere, so don't rely on the effect, but handy:
T_DIM := $(shell tput dim 2> /dev/null)
# Italic: Also doesn't work everywhere. It's quite common for it to work despite terminfo however.
# There aren't any 256 color terminals (or 16..) it should outright break to assume the escapes.
T_GREEN := $(shell ( tput setaf 2 || tput AF 2 ) 2> /dev/null )
T_YELLOWB := $(shell ( tput setaf 3 || tput AF 3 ) 2> /dev/null )
T_CYAN := $(shell ( tput setaf 6 || tput AF 6 ) 2> /dev/null )
T_RED := $(shell ( tput setaf 1 || tput AF 1 ) 2> /dev/null )
T_BOLD := $(shell ( tput bold || tput md ) 2> /dev/null )
# * Italic: Rarely defined - it's common for it to work despite
# terminfo entries and isn't known to cause any recent > 256-color terminals
# to explode. If terminfo says a terminal supports 256 colors - it's fancy enough
# and won't have trouble the escape.
ifeq ($(T_COLORS), 256)
T_ITALIC := "\\033[3m"
T_ITALIC := $(shell ( tput sitm || tput ZH || echo "\\033[3m" ) 2> /dev/null )
# * Half-bright/faint 'dim' mode - rarely works - rarely in terminfo when it does - but it's cool.
# Use it with one of the basic colors to get a fainter version of it.
T_DIM := $(shell ( tput dim || tput mh || [ $(TERM_PROGRAM) = Apple_Terminal ] && echo "\\033[2m") 2> /dev/null )
else
T_ITALIC := ""
T_ITALIC := $(shell ( tput sitm || tput ZH ) 2> /dev/null )
T_DIM := $(shell ( tput dim || tput mh) 2> /dev/null )
endif
T_RESET := $(shell tput sgr0 2> /dev/null)
T_RESET := $(shell ( tput sgr0 || tput me) 2> /dev/null )
#
# A target that prettily shows VAR='$(VAR)' (properly escaped)
# Cool trick: `make show-$var` (e.g. make show-HAVE_DOXYGEN) to quickly see what $var is.
#
show-%:
@echo " $(T_DIM) \$$$*$ = $(T_BOLD)$(T_ITALIC)'$(subst ',''',$($*))'$(T_RESET)" ||:
@echo " $* = $(T_ITALIC)$(T_CYAN)'$(subst ',''',$($*))'$(T_RESET)" ||:
#
# Make everything needed for installing fish
#
all: show-CXX show-CXXFLAGS $(PROGRAMS) $(user_doc) $(share_man) $(TRANSLATIONS) fish.pc share/__fish_build_paths.fish
@echo $(MAKECMDGOALS) | grep -q install || \
echo "\n $(T_GREEN)fish has now been built.$(T_RESET)\n" \
"$(T_BOLD)Run $(T_RESET)$(T_YELLOWB)$(notdir $(MAKE)) install$(T_RESET)$(T_BOLD) to install fish.$(T_RESET)"; true
@echo $(MAKECMDGOALS) | grep -vq install && echo "$(T_GREEN)fish has now been built.$(T_RESET)" ||:
@echo "Run $(T_YELLOWB)$(notdir $(MAKE)) install$(T_RESET) to install fish.$(T_RESET)" ||:
.PHONY: all
#
@ -255,12 +260,14 @@ obj/fish_version.o: FISH-BUILD-VERSION-FILE
# when the source code for the build configuration has changed.
#
configure: configure.ac
@echo "$(T_BOLD)Rehecking config.status; rerunning ./configure if necessary...$(T_RESET)"
@echo "Rechecking config.status; rerunning ./configure if necessary..."$(T_DIM)
$(v) ./config.status --recheck
@echo $(T_RESET)
Makefile: Makefile.in configure
@echo "$(T_WHITE)Checking config.status...$(T_RESET)"
@echo "Checking config.status..."$(T_DIM)
$(v) ./config.status
@echo $(T_RESET)
#
# Build fish with some debug flags specified. This is GCC specific,
@ -280,7 +287,7 @@ prof: all
# directory once Doxygen is done.
#
doc: $(HDR_FILES_SRC) Doxyfile.user $(HTML_SRC) $(HELP_SRC) doc.h $(HDR_FILES) lexicon_filter | show-SED
@echo " doxygen user_doc"
@echo " doxygen $(T_ITALIC)user_doc$(T_RESET)"
$(v)(cat Doxyfile.user; echo INPUT_FILTER=./lexicon_filter; \
echo PROJECT_NUMBER=$(FISH_BUILD_VERSION) | $(SED) "s/-.*//") | \
doxygen - && touch user_doc
@ -408,7 +415,7 @@ doc_src/index.hdr: toc.txt doc_src/index.hdr.in
lexicon.txt: doc_src/commands.hdr $(FUNCTIONS_DIR_FILES) $(COMPLETIONS_DIR_FILES) share/functions/__fish_config_interactive.fish | show-SED
$(v)rm -f lexicon.tmp lexicon_catalog.tmp lexicon_catalog.txt $@
# Scan sources for commands/functions/binaries/colours. If GNU sed was portable, this could be much smarter.
@echo " SED "$@
@echo " SED $(T_ITALIC)$@$(T_RESET)"
$(v)$(SED) <command_list_toc.txt >>lexicon.tmp -n \
-e "s|^.*>\([a-z][a-z_]*\)</a>|'\1'|w lexicon_catalog.tmp" \
-e "s|'\(.*\)'|bltn \1|p"; mv lexicon_catalog.tmp lexicon_catalog.txt; \
@ -438,7 +445,7 @@ lexicon.txt: doc_src/commands.hdr $(FUNCTIONS_DIR_FILES) $(COMPLETIONS_DIR_FILES
#
lexicon_filter: lexicon.txt lexicon_filter.in | show-SED
$(v)rm -f $@.tmp $@
@echo " SED "$@
@echo " SED $(T_ITALIC)$@$(T_RESET)"
# Set the shebang as sed can reside in multiple places.
$(v)$(SED) <$@.in >$@.tmp -e 's|@sed@|'$(SED)'|'
# Scan through the lexicon, transforming each line to something useful to Doxygen.
@ -493,14 +500,14 @@ doc.h: $(HDR_FILES)
# Compile translation files to binary format
#
%.gmo:
@echo " msgfmt "$@
@echo " msgfmt $(T_ITALIC)$@$(T_RESET)"
$(v)msgfmt -o $@ $*.po
#
# Update existing po file or copy messages.pot
#
%.po:messages.pot
@echo " msgmerge "$@
@echo " msgmerge $(T_ITALIC)$@$(T_RESET)"
$(v)if test -f $*.po; then \
msgmerge -U --backup=existing $*.po messages.pot;\
else \
@ -511,7 +518,7 @@ doc.h: $(HDR_FILES)
# Create a template translation object
#
messages.pot: src/*.cpp src/*.h share/completions/*.fish share/functions/*.fish
@echo " xgettext "$@
@echo " xgettext $(T_ITALIC)$@$(T_RESET)"
$(v)xgettext -k_ -kN_ src/*.cpp src/*.h -o messages.pot
$(v)xgettext -j -k_ -kN_ -k--description -LShell --from-code=UTF-8 share/completions/*.fish share/functions/*.fish -o messages.pot
@ -547,7 +554,7 @@ endif
#
share/man: $(HELP_SRC) lexicon_filter | show-FISH_BUILD_VERSION show-SED
-$(v)mkdir -p share/man
@echo " doxygen "$@
@echo " doxygen $(T_ITALIC)$@$(T_RESET)"
$(v)touch share/man
-$(v)rm -Rf share/man/man1
$(v)echo "$(T_DIM)" && \
@ -562,28 +569,28 @@ check-legacy-binaries:
@echo "Checking for legacy binaries..."
$(v)KR_LOC=$(prefix)/bin/key_reader;\
if test -x "$$KR_LOC" && env TERM=dumb "$$KR_LOC" cr | grep -q 26; then\
echo "A key_reader binary was found. You might want to remove this, and use 'fish_key_reader':";\
echo " '$$KR_LOC'";\
echo "$(T_RED)A key_reader binary was found. You might want to remove this, and use 'fish_key_reader':";\
echo " '$$KR_LOC'$(T_RESET)";\
fi;
$(v)SEQLOC=$(prefix)/bin/seq;\
if test -f "$$SEQLOC" && grep -q '\(^#!/.*/fish\|^#!/usr/bin/env fish\)' "$$SEQLOC"; then\
echo "An outdated seq from a previous fish install was found. You should remove it with:";\
echo " rm '$$SEQLOC'";\
echo "$(T_RED)An outdated seq from a previous fish install was found. You should remove it with:";\
echo " rm '$$SEQLOC'$(T_RESET)";\
fi;
$(v)SETCOLOR_LOC=$(prefix)/bin/set_color;\
if test -x "$$SETCOLOR_LOC" && $$SETCOLOR_LOC -v 2>&1 >/dev/null | grep -q "^set_color, version "; then\
echo "An outdated set_color from a previous fish install was found. You should remove it with:";\
echo " rm '$$SETCOLOR_LOC'";\
echo "$(T_RED)An outdated set_color from a previous fish install was found. You should remove it with:";\
echo " rm '$$SETCOLOR_LOC'$(T_RESET)";\
fi;
$(v)MIMEDB_LOC=$(prefix)/bin/mimedb;\
if test -x "$$MIMEDB_LOC" && $$MIMEDB_LOC --version 2>&1 | grep -q "^mimedb, version "; then\
echo "An outdated mimedb binary from a previous fish install was found. You should remove it with:";\
echo " rm '$$MIMEDB_LOC'";\
echo "$(T_RED)An outdated mimedb binary from a previous fish install was found. You should remove it with:";\
echo " rm '$$MIMEDB_LOC'$(T_RESET)";\
fi;
$(v)FISHD_LOC=$(prefix)/bin/fishd;\
if test -x "$$FISHD_LOC" && $$FISHD_LOC --version 2>&1 | grep -q "^fishd: fishd, version "; then\
echo "An outdated fishd binary from a previous fish install was found. You should remove it with:";\
echo " rm '$$FISHD_LOC'";\
echo "$(T_RED)An outdated fishd binary from a previous fish install was found. You should remove it with:";\
echo " rm '$$FISHD_LOC'$(T_RESET)";\
fi;
$(v)true;
.PHONY: check-legacy-binaries
@ -607,7 +614,7 @@ install: all install-force | check-legacy-binaries
fi;
@echo "To set your colors, run $(T_GREEN)$(T_BOLD)fish_config$(T_RESET)"
@echo "To scan your man pages for completions, run $(T_GREEN)$(T_BOLD)fish_update_completions$(T_RESET)"
@echo "To accept autosuggestions (in $(T_BOLD)$(T_DIM)grey$(T_RESET)) as you type, hit $(T_BOLD)ctrl-F$(T_RESET) or right arrow key."
@echo "To accept autosuggestions (in $(T_DIM)grey$(T_RESET)) as you type, hit $(T_BOLD)ctrl-F$(T_RESET) or right arrow key."
@echo
@echo "$(T_BOLD)Have fun! <><$(T_RESET)"
.PHONY: install
@ -626,20 +633,20 @@ xcode-install:
# from failing for (e.g.) missing man pages or extra_dirs outside the
# writeable prefix.
#
install-force: all install-translations
install-force: all install-translations | show-datadir show-sysconfdir show-extra_completionsdir show-extra_functionsdir show-extra_confdir show-mandir
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
$(v)for i in $(PROGRAMS); do\
$(INSTALL) -m 755 $$i $(DESTDIR)$(bindir);\
echo "Installing $(T_BOLD)$$i$(T_RESET)";\
echo " Installing $(T_BOLD)$$i$(T_RESET)";\
true ;\
done;
@echo "Creating sysconfdir tree"
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(sysconfdir)/fish/conf.d
$(v)$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
@echo "Creating datadir tree"
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/completions
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(extra_completionsdir) ||:
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(extra_functionsdir) ||:
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(extra_confdir) ||:
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/functions
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/man/man1
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools
@ -647,27 +654,31 @@ install-force: all install-translations
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config/js
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config/partials
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config/sample_prompts
$(v)$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
$(v)$(INSTALL) -m 644 share/config.fish $(DESTDIR)$(datadir)/fish/
$(v)$(INSTALL) -m 644 share/__fish_build_paths.fish $(DESTDIR)$(datadir)/fish/
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/pkgconfig
@echo "Creating empty vendor/'extra_' directories"
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(extra_completionsdir) ||:
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(extra_functionsdir) ||:
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(extra_confdir) ||:
@echo "Installing pkgconfig file"
$(v)$(INSTALL) -m 644 fish.pc $(DESTDIR)$(datadir)/pkgconfig
@echo "Installing completions...";
@echo "Installing the $(T_BOLD)fish completion libraryn$(T_RESET)...";
$(v)for i in $(COMPLETIONS_DIR_FILES:%='%'); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/completions/; \
true; \
done;
@echo "Installing functions...";
@echo "Installing $(T_BOLD)fish functions$(T_RESET)";
$(v)for i in $(FUNCTIONS_DIR_FILES:%='%'); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/functions/; \
true; \
done;
@echo "Installing man pages...";
@echo "Installing $(T_BOLD)man pages$(T_RESET)";
$(v)for i in share/man/man1/*.1; do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/man/man1/; \
true; \
done;
@echo "Installing tools...";
@echo "Installing $(T_BOLD)fish tools$(T_RESET)";
$(v)for i in share/tools/*.py; do\
$(INSTALL) -m 755 $$i $(DESTDIR)$(datadir)/fish/tools/; \
true; \
@ -692,14 +703,14 @@ install-force: all install-translations
$(INSTALL) -m 755 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/; \
true; \
done;
@echo "Installing user documentation...";
@echo "Installing HTML documentation";
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)
$(v) for i in user_doc/html/* CHANGELOG.md; do \
if test -f $$i; then \
$(INSTALL) -m 644 $$i $(DESTDIR)$(docdir); \
fi; \
done;
@echo "Installing main man pages...";
@echo "Installing more man pages";
$(v)$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1;
$(v) for i in $(MANUALS); do \
$(INSTALL) -m 644 $$i $(DESTDIR)$(mandir)/man1/; \
@ -710,24 +721,58 @@ install-force: all install-translations
#
# Uninstall this fish version
#
uninstall: uninstall-translations
@echo "Uninstalling translations..."
-$(v) for i in $(PROGRAMS); do \
uninstall: uninstall-translations | show-prefix show-bindir show-sysconfdir show-datadir show-docdir show-mandir
@echo
@echo "$(T_BOLD)$(T_YELLOWB)Uninstalling fish$(T_RESET) from configured \$$prefix: $(T_BOLD)$(prefix)$(T_RESET)"
@echo
@echo "Deleting programs: [ $(T_BOLD)$(PROGRAMS)$(T_RESET) ] in $(T_ITALIC)$(bindir)$(T_RESET)"
-$(v)for i in $(PROGRAMS); do \
rm -f $(DESTDIR)$(bindir)/$$i; \
done;
-$(v) rm -rf $(DESTDIR)$(sysconfdir)/fish
@echo "Deleting configuration: $(T_BOLD)$(DESTDIR)$(sysconfdir)/fish/*$(T_RESET)"
-$(v)rm -rf $(DESTDIR)$(sysconfdir)/fish
@echo
@echo "In 5 seconds, $(T_RED)all data$(T_RESET) (includes functions, completions, tools) in"
@echo $$"\t$(T_BOLD)$(DESTDIR)$(datadir)/fish$(T_RESET) will be deleted!"
@echo
@echo $$"If you put things there, $(T_RED)stop now!$(T_RESET) $(T_BOLD)\\c"
@echo $$"$(T_BOLD)5$(T_RESET) \\c"
@sleep 1
@echo $$"$(T_BOLD)4$(T_RESET) \\c"
@sleep 1
@echo $$"$(T_BOLD)3$(T_RESET) \\c"
@sleep 1
@echo $$"$(T_BOLD)2$(T_RESET) \\c"
@sleep 1
@echo $$"$(T_BOLD)1$(T_RESET) \\c"
@sleep 1
@echo ...
@sleep 2
@echo "... deleting $(T_BOLD)$(DESTDIR)$(datadir)/fish/*$(T_RESET)"
-$(v) if test -d $(DESTDIR)$(datadir)/fish; then \
rm -r $(DESTDIR)$(datadir)/fish; \
rm -rf $(DESTDIR)$(datadir)/fish; \
fi
@echo
@echo "Deleting documentation: $(T_BOLD)$(DESTDIR)$(docdir)/*$(T_RESET)"
-$(v) if test -d $(DESTDIR)$(docdir); then \
rm -rf $(DESTDIR)$(docdir);\
fi
@echo
@echo "Deleting pkgconfig file: $(T_BOLD)$(DESTDIR)$(datadir)/pkgconfig/fish.pc$(T_RESET)"
-$(v) if test -f $(DESTDIR)$(datadir)/pkgconfig/fish.pc; then \
rm -f $(DESTDIR)$(datadir)/pkgconfig/fish.pc;\
fi
@echo
@echo $$"Deleting \\c"
@echo "[ $(T_BOLD)"`basename $(MANUALS)`$(T_RESET) $$"] in \\c"
@echo "$(T_ITALIC)$(mandir)/man1$(T_RESET)"
-$(v) for i in $(MANUALS); do \
rm -rf $(DESTDIR)$(mandir)/man1/`basename $$i`*; \
done;
@echo
@echo "$(T_GREEN)Fish (likely) unintalled$(T_RESET)"
@echo
@echo "$(T_BOLD)./configure --prefix=$(T_RESET) to uninstall fish from a different prefix"
.PHONY: uninstall
install-translations: $(TRANSLATIONS)
@ -752,7 +797,7 @@ uninstall-translations:
# How basic files get compiled
#
obj/%.o: src/%.cpp | obj
@echo " CXX "$@
@echo " CXX $(T_ITALIC)$@$(T_RESET)"
$(v)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
#
@ -765,11 +810,12 @@ obj:
# Build the fish program.
#
fish: obj/fish.o $(FISH_OBJS) $(EXTRA_PCRE2)
@echo " CXXLD "$@
@echo " CXXLD $(T_ITALIC)$@$(T_RESET)"
$(v)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS_FISH) $(FISH_OBJS) obj/fish.o $(LIBS) -o $@
$(PCRE2_LIB): $(PCRE2_H)
$(v)$(MAKE) V=$(V) -C $(PCRE2_DIR) libpcre2-$(PCRE2_WIDTH).la
@echo " MAKE $(T_ITALIC)$@$(T_RESET)"
@$(MAKE) V=$(V) -C $(PCRE2_DIR) libpcre2-$(PCRE2_WIDTH).la
$(PCRE2_H):
$(v)(cd $(PCRE2_DIR) && ./config.status)
@ -778,21 +824,21 @@ $(PCRE2_H):
# Build the fish_tests program.
#
fish_tests: $(FISH_TESTS_OBJS) $(EXTRA_PCRE2)
@echo " CXXLD "$@
@echo " CXXLD $(T_ITALIC)$@$(T_RESET)"
$(v)$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $(FISH_TESTS_OBJS) $(LIBS) -o $@
#
# Build the fish_indent program.
#
fish_indent: $(FISH_INDENT_OBJS) $(EXTRA_PCRE2)
@echo " CXXLD "$@
@echo " CXXLD $(T_ITALIC)$@$(T_RESET)"
$(v)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(FISH_INDENT_OBJS) $(LIBS) -o $@
#
# Build the fish_key_reader program to show input from the terminal.
#
fish_key_reader: $(FISH_KEYREAD_OBJS) $(EXTRA_PCRE2)
@echo " CXXLD "$@
@echo " CXXLD $(T_ITALIC)$@$(T_RESET)"
$(v)$(CXX) $(CXXFLAGS) $(LDFLAGS_FISH) $^ $(LIBS) -o $@
#
@ -807,7 +853,7 @@ fish_key_reader: $(FISH_KEYREAD_OBJS) $(EXTRA_PCRE2)
# behind.
#
depend:
@echo "$(T_BOLD)Running makedepend...$(T_RESET)"
@echo $(T_ITALIC)"Running makedepend..."$(T_RESET)
$(v)mkdir -p /tmp/fish_make_depend/src
$(v)cp src/*.cpp src/*.h /tmp/fish_make_depend/src
$(v)cp config.h /tmp/fish_make_depend/
@ -818,7 +864,7 @@ depend:
.PHONY: depend
#
# Lint the code. This only deals with C++ files.
# Lint the code. This only deals with C++
#
lint:
$(v)build_tools/lint.fish $(CXX) $(CXXFLAGS) $(CPPFLAGS)
@ -985,9 +1031,9 @@ obj/fish_indent.o: src/input.h src/output.h src/parse_constants.h
obj/fish_indent.o: src/parse_tree.h src/tokenizer.h src/print_help.h
obj/fish_indent.o: src/wutil.h
obj/fish_key_reader.o: config.h src/signal.h src/common.h src/fallback.h
obj/fish_key_reader.o: src/env.h src/input.h src/input_common.h src/proc.h
obj/fish_key_reader.o: src/io.h src/parse_tree.h src/parse_constants.h
obj/fish_key_reader.o: src/tokenizer.h src/print_help.h src/reader.h
obj/fish_key_reader.o: src/env.h src/input.h src/input_common.h
obj/fish_key_reader.o: src/print_help.h src/proc.h src/io.h src/parse_tree.h
obj/fish_key_reader.o: src/parse_constants.h src/tokenizer.h src/reader.h
obj/fish_key_reader.o: src/complete.h src/highlight.h src/color.h src/wutil.h
obj/fish_tests.o: config.h src/signal.h src/builtin.h src/common.h
obj/fish_tests.o: src/fallback.h src/color.h src/complete.h src/env.h
@ -1011,10 +1057,10 @@ obj/highlight.o: src/highlight.h src/history.h src/wutil.h src/output.h
obj/highlight.o: src/parse_tree.h src/tokenizer.h src/parse_util.h src/path.h
obj/highlight.o: src/wildcard.h src/complete.h
obj/history.o: config.h src/common.h src/fallback.h src/signal.h src/env.h
obj/history.o: src/history.h src/wutil.h src/iothread.h src/lru.h
obj/history.o: src/history.h src/wutil.h src/io.h src/iothread.h src/lru.h
obj/history.o: src/parse_constants.h src/parse_tree.h src/tokenizer.h
obj/history.o: src/path.h src/reader.h src/complete.h src/highlight.h
obj/history.o: src/color.h src/sanity.h
obj/history.o: src/color.h
obj/input.o: config.h src/common.h src/fallback.h src/signal.h src/env.h
obj/input.o: src/event.h src/input.h src/input_common.h src/io.h src/output.h
obj/input.o: src/color.h src/parser.h src/expand.h src/parse_constants.h

View File

@ -64,9 +64,11 @@ fish requires a number of utilities to operate, which should be present on any U
Translation support requires the gettext program.
Usage output for builtin functions is generated on-demand from the installed manpages using `nroff` and `ul`.
Some optional features of fish, such as the manual page completion parser and the web configuration tool, require Python.
In order to generate completions from man pages compressed with either lzma or xz, you may need to install an extra Python package. Python versions prior to 2.6 are not supported. For Python versions 2.6 to 3.2 you need to install the module `backports.lzma`. How to install it depends on your system and how you installed Python. Most Linux distributions should include it as a package named `backports-lzma` (or similar). From version 3.3 onwards, Python already includes the required module.
In order to generate completions from man pages compressed with either lzma or xz, you may need to install an extra Python package. Python versions prior to 2.6 are not supported. To process lzma-compresed manpages, backports.lzma is needed for Python 3.2 or older. From version 3.3 onwards, Python already includes the required module.
## Packages for Linux

View File

@ -29,8 +29,6 @@ The following options are available:
- `-s` or `--on-signal SIGSPEC` tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP).
- `-B` or `--shadow-builtin` must be specified if the function name is the same as a builtin. Specifying this flag indicates your acknowledgement that you are wrapping or replacing the builtin command. This is a safety feature to make it harder for people to inadvertently break the shell by doing things like `function test; return 0; end`. If the function name is not currently a builtin using this flag will produce an error. If you want to write a function that provides a builtin to an older version of fish you need to add something like `builtin --names | grep -q '^cmd$'; and return` to the top of the function script (where `cmd` is the name of the builtin/function). That will keep your script from replacing the builtin with your function on the newer fish version while allowing your function to provide similar functionality on older versions of fish.
- `-S` or `--no-scope-shadowing` allows the function to access the variables of calling functions. Normally, any variables inside the function that have the same name as variables from the calling function are "shadowed", and their contents is independent of the calling function.
- `-V` or `--inherit-variable NAME` snapshots the value of the variable `NAME` and defines a local variable with that same name and value when the function is executed.

View File

@ -34,7 +34,7 @@ The following options are available:
- `-p` or `--prefix` searches or deletes items in the history that begin with the specified text string. This is not currently supported by the `--delete` flag.
- `-t` or `--with-time` prefixes the output of each displayed history entry with the time it was recorded in the format "%Y-%m-%d %H:%M:%S" in your local timezone.
- `-t` or `--with-time` outputs the date and time ("%Y-%m-%d %H:%M:%S") history items were recorded at on a line starting with "#" before each history entry.
\subsection history-examples Example

View File

@ -960,7 +960,7 @@ function hybrid_bindings --description "Vi-style bindings that inherit emacs-sty
for mode in default insert visual
fish_default_key_bindings -M $mode
end
fish_vi_key_bindings
fish_vi_key_bindings --no-erase
end
set -g fish_key_bindings hybrid_bindings
\endfish
@ -1025,7 +1025,20 @@ You can change these key bindings using the <a href="commands.html#bind">bind</a
Vi mode allows for the use of Vi-like commands at the prompt. Initially, <a href="#vi-mode-insert">insert mode</a> is active. @key{Escape} enters <a href="#vi-mode-command">command mode</a>. The commands available in command, insert and visual mode are described below. Vi mode shares <a href="#shared-binds">some bindings</a> with <a href="#emacs-mode">Emacs mode</a>.
When in vi-mode, the <a href="fish_mode_prompt.html">`fish_mode_prompt`</a> function will display a mode indicator to the left of the prompt. The `fish_vi_cursor` function is available to change the cursor's shape depending on the mode in supported terminals.
It is also possible to add all emacs-mode bindings to vi-mode by using something like
\fish
function fish_user_key_bindings
# Execute this once per mode that emacs bindings should be used in
fish_default_key_bindings -M insert
# Without an argument, fish_vi_key_bindings will default to
# resetting all bindings.
# The argument specifies the initial mode (insert, "default" or visual).
fish_vi_key_bindings insert
end
\endfish
When in vi-mode, the <a href="fish_mode_prompt.html">`fish_mode_prompt`</a> function will display a mode indicator to the left of the prompt. The `fish_vi_cursor` function will be used to change the cursor's shape depending on the mode in supported terminals. To disable this feature, override it with an empty function.
\subsubsection vi-mode-command Command mode
@ -1129,15 +1142,15 @@ Note that functions cannot be started in the background. Functions that are stop
\section initialization Initialization files
On startup, Fish evaluates a number of configuration files, which can be used to control the behavior of the shell.
On startup, Fish evaluates a number of configuration files, which can be used to control the behavior of the shell. The location of these configuration variables is controlled by a number of environment variables, and their default or usual location is given below.
Configuration files are evaluated in the following order:
- Configuration shipped with fish, which should not be edited, usually `/usr/share/fish/config.fish`.
- System-wide configuration files, where administrators can include initialization that should be run for all users on the system - similar to `/etc/profile` for POSIX-style shells - usually `/etc/fish/config.fish`;
- Configuration shipped with fish, which should not be edited, in `$__fish_datadir/config.fish` (usually `/usr/share/fish/config.fish`).
- System-wide configuration files, where administrators can include initialization that should be run for all users on the system - similar to `/etc/profile` for POSIX-style shells - in `$__fish_sysconfdir` (usually `/etc/fish/config.fish`);
- Configuration snippets in files ending in `.fish`, in the directories:
- `~/.config/fish/conf.d/`
- `/etc/fish/conf.d`
- `/usr/share/fish/vendor_conf.d`
- `$XDG_CONFIG_HOME/fish/conf.d` (by default, `~/.config/fish/conf.d/`)
- `$__fish_sysconfdir/conf.d` (by default, `/etc/fish/conf.d`)
- `/usr/share/fish/vendor_conf.d` (set at compile time; by default, `$__fish_datadir/conf.d`)
If there are multiple files with the same name in these directories, only the first will be executed.
@ -1145,7 +1158,7 @@ Configuration files are evaluated in the following order:
These paths are controlled by parameters set at build, install, or run time, and may vary from the defaults listed above.
This wide search may be confusing. If you are unsure, use `~/.config/fish/config.fish`.
This wide search may be confusing. If you are unsure where to put your own customisations, use `~/.config/fish/config.fish`.
These files are all executed on the startup of every shell. If you want to run a command only on starting an interactive shell, use the exit status of the command `status --is-interactive` to determine if the shell is interactive. If you want to run a command only when using a login shell, use `status --is-login` instead. This will speed up the starting of non-interactive or non-login shells.

View File

@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
scriptversion=2013-12-25.23; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" "" $nl"
IFS=" $tab$nl"
# set DOITPROG to echo to test this script
# Set DOITPROG to "echo" to test this script.
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
@ -97,7 +82,7 @@ dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@ -137,46 +122,57 @@ while test $# -ne 0; do
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
@ -207,6 +203,15 @@ if test $# -eq 0; then
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
@ -223,16 +228,16 @@ if test -z "$dir_arg"; then
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
u_plus_rw=
else
u_plus_rw='% 200'
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
u_plus_rw=
else
u_plus_rw=,u+rw
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
@ -269,41 +274,15 @@ do
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
@ -314,74 +293,74 @@ do
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
@ -391,53 +370,51 @@ do
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set -f
set fnord $dstdir
shift
$posix_glob set +f
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
@ -472,15 +449,12 @@ do
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
@ -493,24 +467,24 @@ do
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1

View File

@ -17,9 +17,16 @@ function __fish_brew_using_command
end
function __fish_brew_formulae
set -l formuladir (brew --repository)/Library/Formula/
# __fish_complete_suffix .rb
ls $formuladir/*.rb | sed 's/.rb$//' | sed "s|^$formuladir||"
# list all local formula, do not use `brew search some_text` against searching online
# TODO fix the problem with `tap-pin`, tap-pin will modify the priority
# If you pin your custom tap for VIM, you should
# `brew install homebrew/core/vim` to install VIM from `core` repo
# `brew install vim` to install VIM from more prior repo
# but `brew search` won't change display for custom VIM and core VIM
# 'vim' for core VIM
# 'custUser/custRepo/vim' for more prior VIM
# more info: https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/brew-tap.md#formula-duplicate-names
brew search
end
function __fish_brew_installed_formulas

View File

@ -6,7 +6,15 @@ function __fish_git_commits
# This allows filtering by subject with the new pager!
# Because even subject lines can be quite long,
# trim them (abbrev'd hash+tab+subject) to 73 characters
command git log --pretty=tformat:"%h"\t"%s" --all ^/dev/null \
command git log --pretty=tformat:"%h"\t"%s" --all --max-count=1000 ^/dev/null \
| string replace -r '(.{73}).+' '$1…'
end
function __fish_git_recent_commits
# Like __fish_git_commits, but not on all branches and limited to
# the last 50 commits. Used for fixup, where only the current branch
# and the latest commits make sense.
command git log --pretty=tformat:"%h"\t"%s" --max-count=50 ^/dev/null \
| string replace -r '(.{73}).+' '$1…'
end
@ -396,7 +404,7 @@ complete -c git -n '__fish_git_needs_command' -a commit -d 'Record changes to th
complete -c git -n '__fish_git_using_command commit' -l amend -d 'Amend the log message of the last commit'
complete -f -c git -n '__fish_git_using_command commit' -a '(__fish_git_modified_files)'
complete -f -c git -n '__fish_git_using_command commit' -l fixup -d 'Fixup commit to be used with rebase --autosquash'
complete -f -c git -n '__fish_git_using_command commit; and __fish_contains_opt fixup' -a '(__fish_git_commits)'
complete -f -c git -n '__fish_git_using_command commit; and __fish_contains_opt fixup' -a '(__fish_git_recent_commits)'
# TODO options
### diff

778
share/completions/p4.fish Normal file
View File

@ -0,0 +1,778 @@
# Fish completions for Perforce (p4) SCM
# Based on the list of commands from
# https://www.perforce.com/perforce/r16.1/manuals/cmdref/
# Author: Boris Aranovich https://github.com/nomaed
#########################################################
### p4 command parsing
#########################################################
function __fish_print_p4_client_name -d "Use `p4 info` output to query for current client name"
set -l p4info (p4 info -s 2> /dev/null)
if string match -qr '^Client unknown' $p4info
return
end
string match -r '^Client name: .+' $p4info | string replace 'Client name: ' ''
end
#########################################################
function __fish_print_p4_user_name -d "Use `p4 info` output to query for current client name"
string match -r '^User name: .+' (p4 info 2> /dev/null) | string replace 'User name: ' ''
end
#########################################################
function __fish_print_p4_changelists -d "Reformat output from `p4 changes` to simple format. Specify 'detailed!' as first argument to use username@workspace prefix"
set -l detailed
if test -n "$argv"
and test $argv[1] = "detailed!"
set detailed true
set -e argv[1]
end
# The format of `p4 changes -L` is as follows, for each changelist:
# Change 1234 on YYYY/MM/DD by user@workspace *status*\n
# \n
# \t Description text line\n
# \t Description text another line\n
# \n
set -l changes (p4 changes -L $argv)
set -l result
for line in (string trim -- $changes)
if test -z "$line"
continue
end
# see output format ^^^
set -l change_match (string match -ar '^Change ([0-9]+) on [0-9/]+ by (\S+).*$' $line)
if test -n "$change_match"
if test -n "$result"
echo $result
set result
end
set result $change_match[2]\t
if test -n "$detailed"
set result $result $change_match[3]:
end
else
set result $result $line
end
end
if test -n "$result"
echo $result
end
end
#########################################################
function __fish_print_p4_opened_files -d "Use `p4 diff` to output the names of all opened files"
# p4 opened -s | sed 's/#.*//' | p4 -x - where | awk '/^\// {print $3}'
# p4 opened -s | string replace -ar '(^\S+).*$' '$1' | p4 -x - where | string replace -ar '\S+\s\S+\s(\S+)' '$1'
string replace -a "$PWD/" '' (p4 diff -sa -sb -sr)
end
#########################################################
function __fish_print_p4_branches -d "Prints the list of all defined branches on the server"
set -l branches (p4 branches)
for branch in $branches
# "Branch branch-name YYYY/MM/DD 'description text'"
set -l matches (string match -ar '^Branch\s+(\S+)[^\']+\'(.+)\'$' $branch)
if not set -q matches[2]
# skip $branch if no match for branch name with description
continue
end
# matches[2] = branch name; matches[3] = description
echo -n $matches[2]
if not set -q matches[3]
echo -n \t$matches[3]
end
echo
end
end
#########################################################
function __fish_print_p4_streams
# I do not have an example of p4 streams output
#p4 streams 2> /dev/null
end
#########################################################
function __fish_print_p4_users -d "Lists perforce users suitable for list of completions"
# `p4 users` output format:
# "username <email@address> (Full Name) accessed YYYY/MM/DD"
# function will output it as:
# username[TAB]Full Name <email@address>
string replace -ar '(^\S+) <([^>]+)> \(([^\)]+)\).*$' '$1'\t'$3 <$2>' (p4 users)
end
#########################################################
function __fish_print_p4_workspaces -d "Lists current user's workspaces"
set -l user (__fish_print_p4_user_name)
if test -z "$user"
return
end
# "Client clientname YYYY/MM/DD root /home/user/workspace/path 'description text'"
string replace -ar '^Client (\S+) \S+ root (\S+) \'(.+)\'$' '$1'\t'$3' (p4 clients -u $user)
end
#########################################################
function __fish_print_p4_workspace_changelists -d "Lists all changelists for current user"
set -l client (__fish_print_p4_client_name)
if test -n "$client"
__fish_print_p4_changelists -c $client $argv
end
end
#########################################################
function __fish_print_p4_pending_changelists -d "Lists all *pending* changelists. If 'default' argument is provided, default changelist will also be listed"
if set -q argv[1]
and test $argv[1] = "default"
echo default\tDefault changelist
end
__fish_print_p4_workspace_changelists -s pending
end
#########################################################
function __fish_print_p4_shelved_changelists -d "Lists all changelists with *shelved* files"
__fish_print_p4_workspace_changelists -s shelved
end
#########################################################
### completion helpers
#########################################################
function __fish_print_p4_commands_list -d "Lists p4 commands"
set -l commands add annotate attribute branch branches change changes changelist changelists clean client clients copy counter counters cstat delete depot depots describe diff diff2 dirs edit filelog files fix fixes flush fstat grep group groups have help info integ integrate integrated interchanges istat job jobs key keys label labels labelsync list lock logger login logout merge move opened passwd populate print protect protects prune rec reconcile rename reopen resolve resolved revert review reviews set shelve status sizes stream streams submit sync tag tickets unlock unshelve update user users where workspace workspaces
for i in $commands
echo $i
end
end
#########################################################
function __fish_print_p4_env_vars -d "Lists environment variables that can be consumed by perforce"
set -l env_vars P4CLIENT P4PORT P4PASSWD P4USER P4CONFIG P4DIFF P4EDITOR P4MERGE P4CHARSET P4TRUST P4PAGER PWD TMP TEMP P4TICKETS P4LANGUAGE P4LOGINSSO P4COMMANDCHARSET P4DIFFUNICODE P4MERGEUNICODE P4CLIENTPATH P4AUDIT P4JOURNAL P4LOG P4PORT P4ROOT P4DEBUG P4NAME P4SSLDIR
for var in $env_vars
echo $var
end
end
#########################################################
function __fish_print_p4_file_types -d "Lists all of available file modes"
set -l base_types text binary symlink apple resource unicode utf16
for type in $base_types
printf '%s\t%s\n' $type+m 'always set modtime' $type+w 'always writeable' $type+x 'exec bit set' $type+k '$Keyword$ expansion of Id, Header, Author, Date, DateUTC, DateTime, DateTimeUTC, DateTimeTZ, Change, File, Revision' $type+ko '$Keyword$ expansion of Id, Header only' $type+l 'exclusive open: disallow multiple opens' $type+C 'server stores compressed file per revision' $type+D 'server stores deltas in RCS format' $type+F 'server stores full file per revision' $type+S 'server stores only single head rev., or specify number to <n> of revisions' $type+X 'server runs archive trigger to access files'
end
end
#########################################################
function __fish_print_p4_help_keywords -d "Keywords for `p4 help`"
echo administration\t"Help on specialized administration topics"
echo charset\t"Describes how to control Unicode translation"
echo commands\t"Lists all the Perforce commands"
echo configurables\t"Describes all of the server configuration variables"
echo dvcs\t"Describes decentralized version control with Perforce"
echo environment\t"Lists the Perforce environment variables and their meanings"
echo filetypes\t"Lists the Perforce filetypes and their meanings"
echo jobview\t"Describes Perforce jobviews"
echo legal\t"Legal and license information"
echo networkaddress\t"Help on network address syntax"
echo replication\t"Describes specialized replication topics"
echo revisions\t"Describes Perforce revision specifiers"
echo simple\t"Provides short descriptions of the eight most basic Perforce commands"
echo usage\t"Lists the six options available with all Perforce commands"
echo views\t"Describes the meaning of Perforce views"
end
#########################################################
function __fish_print_p4_diff_options -d "Options for `p4 diff -d`"
echo n\t"RCS output format, showing additions and deletions made to the file and associated line ranges"
echo c\t"context output format, showing line number ranges and N lines of context around the changes" #
echo s\t"summary output format, showing only the number of chunks and lines added, deleted, or changed"
echo u\t"unified output format, showing added and deleted lines with N lines of context, in a form compatible with the patch(1) utility" #
echo l\t"ignore line-ending (CR/LF) convention when finding diffs"
echo b\t"ignore changes made within whitespace; this option implies -dl"
echo w\t"ignore whitespace altogether; this option implies -dl"
end
#########################################################
function __fish_print_p4_resolve_options -d "Options for `p4 merge` using -a, -A and -d"
switch "$argv[1]"
case a
echo m\t"Automatic: accept the Perforce-recommended file revision (yours, their, merge)"
echo y\t"Accept Yours, ignore theirs"
echo t\t"Accept Theirs"
echo s\t"Safe Accept: merge if no conflict, ignore file otherwise"
echo f\t"Force Accept: conflicted changes will leave conflict markers in the file"
case A
echo b\t"Resolve attributes set by p4 attribute"
echo b\t"Resolve file branching; that is, integrations where the source is edited and the target is deleted"
echo c\t"Resolve file content changes"
echo d\t"Integrations where the source is deleted and target is deleted"
echo t\t"Filetype changes"
echo m\t"Move and renames"
case d
echo b\t"Ignore whitespace-only changes (for instance, a tab replaced by eight spaces)"
echo w\t"Ignore whitespace altogether (for instance, deletion of tabs or other whitespace)"
echo l\t"Ignore differences in line-ending convention"
end
end
#########################################################
function __fish_print_p4_parallel_options -d "Values for --parallel option in various commands"
set -l mode
if test -n "$argv"
set mode $argv[1]
end
# for now only looks that mode is set, later it will need to have a specific setting
echo 'threads='\t"sends files concurrently using N independent network connections"
echo 'batch='\t"specifies the number of files in a batch"
test "$mode"
or echo 'batchsize='\t"specifies the number of bytes in a batch"
echo 'min='\t"specifies the minimum number of files in a parallel sync"
test "$mode"
or echo 'minsize='\t"specifies the minimum number of bytes in a parallel sync"
end
#########################################################
function __fish_print_p4_submit_options -d "Options for `p4 submit`"
echo 'submitunchanged'\t"Submit all open files (default behavior)"
echo 'submitunchanged+reopen'\t"Submit all open files + reopen to default changelist"
echo 'revertunchanged'\t"Revert unmodified files, submit all the rest"
echo 'revertunchanged+reopen'\t"Revert unmodified files, submit all the rest + reopen them in default changelist"
echo 'leaveunchanged'\t"Move unchanged files to default changelist, submit all the rest"
echo 'leaveunchanged+reopen'\t"Submit only modified files + reopen all (modified and unmodified) in default changelist"
end
#########################################################
function __fish_print_p4_noretransfer_options -d "Options for `p4 submit --noretransfer`"
echo 1\t"server avoids re-transferring files that have already been archived after a failed submit operation"
echo 0\t"server re-transfers all files after a failed submit operation"
end
#########################################################
function __fish_print_p4_integrate_output_options -d "Options for `p4 resolve -O`"
echo b\t"outputs the base revision for the merge (if any)"
echo r\t"outputs the resolves that are being scheduled"
end
#########################################################
function __fish_print_p4_integrate_resolve_options -d "Options for `p4 resolve -R`"
echo b\t"schedules a branch resolve instead of branching the target files automatically"
echo d\t"schedules a delete resolve instead of deleting the target files automatically"
echo s\t"skips cherry-picked revisions that have already been integrated"
end
#########################################################
function __fish_p4_not_in_command -d "Checks that prompt is not inside of p4 command"
for i in (commandline -opc)
if contains -- $i (__fish_print_p4_commands_list)
return 1
end
end
return 0
end
#########################################################
# Perforce command is a single word that comes either as first argument
# or directly after global options.
# To test whether we're in command, it's enough that a command will appear
# in the arguments, even though if more than a single command is specified,
# p4 will complain.
function __fish_p4_is_using_command -d "Checks if prompt is in a specific command"
if contains -- $argv[1] (commandline -opc)
return 0
end
return 1
end
#########################################################
function __fish_p4_register_command -d "Adds a completion for a specific command"
complete -c p4 -n "__fish_p4_not_in_command" -a $argv[1] $argv[2..-1]
end
#########################################################
function __fish_p4_register_command_option -d "Adds a specific option for a command"
complete -c p4 -n "__fish_p4_is_using_command $argv[1]" $argv[2..-1]
end
#########################################################
### global options -- can be used before any command
#########################################################
complete -c p4 -n __fish_p4_not_in_command -s b -x -d 'Specifies a batch size (number of arguments) to use when processing a command from a file with the -x argfile option'
complete -c p4 -n __fish_p4_not_in_command -s c -x -d 'Overrides any P4CLIENT setting with the specified client name'
complete -c p4 -n __fish_p4_not_in_command -s d -r -d 'Overrides any PWD setting (current working directory) and replaces it with the specified directory'
complete -c p4 -n __fish_p4_not_in_command -s I -d 'Specify that progress indicators, if available, are desired. This option is not compatible with the -s and -G options'
complete -c p4 -n __fish_p4_not_in_command -s G -d 'Causes all output (and batch input for form commands with -i) to be formatted as marshalled Python dictionary objects'
complete -c p4 -n __fish_p4_not_in_command -s H -x -a '(__fish_print_hostnames)' -d 'Overrides any P4HOST setting and replaces it with the specified hostname'
complete -c p4 -n __fish_p4_not_in_command -s p -x -d 'Overrides any P4PORT setting with the specified protocol:host:port'
complete -c p4 -n __fish_p4_not_in_command -s P -x -d 'Overrides any P4PASSWD setting with the specified password.'
complete -c p4 -n __fish_p4_not_in_command -s r -x -d 'Specifies the number of times to retry a command (notably, p4 sync) if the network times out.'
complete -c p4 -n __fish_p4_not_in_command -s s -d 'Prepends a descriptive field (for example, text:, info:, error:, exit:) to each line of output produced by a Perforce command. This is most often used when scripting.'
complete -c p4 -n __fish_p4_not_in_command -s u -x -a '(__fish_print_p4_users)' -d 'Overrides any P4USER, USER, or USERNAME setting with the specified user name.'
complete -c p4 -n __fish_p4_not_in_command -s x -r -d 'Instructs Perforce to read arguments, one per line, from the specified file. If file is a single hyphen (-), then standard input is read.'
complete -c p4 -n __fish_p4_not_in_command -s C -x -a '(__fish_print_encodings)' -d 'Overrides any P4CHARSET setting with the specified character set.'
complete -c p4 -n __fish_p4_not_in_command -s Q -x -a '(__fish_print_encodings)' -d 'Overrides any P4COMMANDCHARSET setting with the specified character set.'
complete -c p4 -n __fish_p4_not_in_command -s L -x -d 'This feature is reserved for system integrators.'
complete -c p4 -n __fish_p4_not_in_command -s z -x -d 'Causes output of many reporting commands to be in the same tagged format as that generated by p4 fstat.'
complete -c p4 -n __fish_p4_not_in_command -s q -d 'Quiet mode; suppress all informational message and report only warnings or errors.'
complete -c p4 -n __fish_p4_not_in_command -s V -d 'Displays the version of the p4 application and exits.'
complete -c p4 -n __fish_p4_not_in_command -s h -d 'Displays basic usage information and exits.'
#########################################################
### sub-commands
#########################################################
__fish_p4_register_command add -d "Open a new file to add it to the depot"
__fish_p4_register_command annotate -d "Print file lines along with their revisions"
__fish_p4_register_command attribute -f -d "Set per-revision attributes on revisions"
__fish_p4_register_command branch -f -d "Create or edit a branch specification"
__fish_p4_register_command branches -f -d "Display list of branches"
__fish_p4_register_command change -f -d "Create or edit a changelist description"
__fish_p4_register_command changes -f -d "Display list of pending and submitted changelists"
__fish_p4_register_command changelist -f -d "Create or edit a changelist description"
__fish_p4_register_command changelists -f -d "Display list of pending and submitted changelists"
__fish_p4_register_command clean -d "Delete or refresh local files to match depot state"
__fish_p4_register_command client -f -d "Create or edit a client specification and its view"
__fish_p4_register_command clients -f -d "Display list of known clients"
__fish_p4_register_command copy -d "Schedule copy of latest rev from one file to another"
__fish_p4_register_command counter -f -d "Display, set, or delete a counter"
__fish_p4_register_command counters -f -d "Display list of known counters"
__fish_p4_register_command cstat -f -d "Dump change/sync status for current client"
__fish_p4_register_command delete -d "Open an existing file to delete it from the depot"
__fish_p4_register_command depot -f -d "Create or edit a depot specification"
__fish_p4_register_command depots -f -d "Display list of depots"
__fish_p4_register_command describe -x -d "Display a changelist description"
__fish_p4_register_command diff -d "Display diff of client file with depot file"
__fish_p4_register_command diff2 -d "Display diff of two depot files"
__fish_p4_register_command dirs -f -d "List subdirectories of a given depot directory"
__fish_p4_register_command edit -d "Open an existing file for edit"
__fish_p4_register_command filelog -d "List revision history of files"
__fish_p4_register_command files -d "List files in the depot"
__fish_p4_register_command fix -f -d "Mark jobs as being fixed by named changelists"
__fish_p4_register_command fixes -f -d "List what changelists fix what job"
__fish_p4_register_command flush -d "Fake a 'p4 sync' by not moving files"
__fish_p4_register_command fstat -d "Dump file info"
__fish_p4_register_command grep -d "Print lines from text files matching a pattern"
__fish_p4_register_command group -f -d "Change members of a user group"
__fish_p4_register_command groups -f -d "List groups (of users)"
__fish_p4_register_command have -f -d "List revisions last synced"
__fish_p4_register_command help -f -d "Print the requested help message"
__fish_p4_register_command info -f -d "Print out client/server information"
__fish_p4_register_command integ -d "Schedule integration from one file to another"
__fish_p4_register_command integrate -d "Schedule integration from one file to another"
__fish_p4_register_command integrated -f -d "Show integrations that have been submitted"
__fish_p4_register_command interchanges -f -d "Report changes that have not yet been integrated"
__fish_p4_register_command istat -f -d "Show integrations needed for a stream"
__fish_p4_register_command job -f -d "Create or edit a job (defect) specification"
__fish_p4_register_command jobs -f -d "Display list of jobs"
__fish_p4_register_command key -f -d "Display, set, or delete a key/value pair"
__fish_p4_register_command keys -f -d "Display list of known keys and their values"
__fish_p4_register_command label -f -d "Create or edit a label specification and its view"
__fish_p4_register_command labels -f -d "Display list of labels"
__fish_p4_register_command labelsync -f -d "Synchronize label with the current client contents"
__fish_p4_register_command list -d "Create an in-memory (label) list of depot files"
__fish_p4_register_command lock -d "Lock an opened file against changelist submission"
__fish_p4_register_command logger -f -d "Report what jobs and changelists have changed"
__fish_p4_register_command login -f -d "Login to Perforce by obtaining a session ticket"
__fish_p4_register_command logout -f -d "Logout of Perforce by removing or invalidating a ticket"
__fish_p4_register_command merge -d "Schedule merge (integration) from one file to another"
__fish_p4_register_command move -d "Moves files from one location to another"
__fish_p4_register_command opened -d "Display list of files opened for pending changelist"
__fish_p4_register_command passwd -f -d "Set the user's password on the server (and Windows client)"
__fish_p4_register_command populate -d "Populate a branch or stream with files"
__fish_p4_register_command print -d "Retrieve a depot file to the standard output"
__fish_p4_register_command protect -f -d "Modify protections in the server namespace"
__fish_p4_register_command protects -f -d "Display protections in place for a given user/path"
__fish_p4_register_command prune -d "Remove unmodified branched files from a stream"
__fish_p4_register_command rec -f -d "Reconcile client to offline workspace changes"
__fish_p4_register_command reconcile -f -d "Reconcile client to offline workspace changes"
__fish_p4_register_command rename -d "Moves files from one location to another"
__fish_p4_register_command reopen -d "Change the type or changelist number of an opened file"
__fish_p4_register_command resolve -d "Merge open files with other revisions or files"
__fish_p4_register_command resolved -d "Show files that have been merged but not submitted"
__fish_p4_register_command revert -d "Discard changes from an opened file"
__fish_p4_register_command review -f -d "List and track changelists (for the review daemon)"
__fish_p4_register_command reviews -d "Show what users are subscribed to review files"
__fish_p4_register_command set -x -d "Set variables in the registry (Windows only)"
__fish_p4_register_command shelve -x -d "Store files from a pending changelist into the depot"
__fish_p4_register_command status -f -d "Preview reconcile of client to offline workspace changes"
__fish_p4_register_command sizes -d "Display size information for files in the depot"
__fish_p4_register_command stream -f -d "Create or edit a stream specification"
__fish_p4_register_command streams -f -d "Display list of streams"
__fish_p4_register_command submit -d "Submit open files to the depot"
__fish_p4_register_command sync -f -d "Synchronize the client with its view of the depot"
__fish_p4_register_command tag -d "Tag files with a label"
__fish_p4_register_command tickets -f -d "Display list of session tickets for this user"
__fish_p4_register_command unlock -d "Release a locked file but leave it open"
__fish_p4_register_command unshelve -d "Restore shelved files from a pending changelist"
__fish_p4_register_command update -f -d "Update the client with its view of the depot"
__fish_p4_register_command user -f -d "Create or edit a user specification"
__fish_p4_register_command users -f -d "Display list of known users"
__fish_p4_register_command where -d "Show how file names map through the client view"
__fish_p4_register_command workspace -f -d "Create or edit a client specification and its view"
__fish_p4_register_command workspaces -f -d "Display list of known clients"
#########################################################
### sub-command options
#########################################################
#-----------------------------------------------------
#--> Help
#-----------------------------------------------------
# help
__fish_p4_register_command_option help -f -a '(__fish_print_p4_help_keywords)'
# info
__fish_p4_register_command_option info -s s -d "Short output (removes information that requires DB search)"
#-----------------------------------------------------
#--> Client workspace
#-----------------------------------------------------
# clean
__fish_p4_register_command_option clean -a '(__fish_print_p4_opened_files)'
__fish_p4_register_command_option clean -s a -d "Added files: Find files in the workspace that have no corresponding files in the depot and delete them"
__fish_p4_register_command_option clean -s d -d "Deleted files: Find those files in the depot that do not exist in your workspace and add them to the workspace"
__fish_p4_register_command_option clean -s e -d "Edited files: Find files in the workspace that have been modified and restore them to the last file version that has synced from the depot"
__fish_p4_register_command_option clean -s I -d "Do not perform any ignore checking; ignore any settings specified by P4IGNORE for added files"
__fish_p4_register_command_option clean -s l -d "Display output in local file syntax with relative paths, similar to the workspace-centric view of p4 status"
__fish_p4_register_command_option clean -s n -d "Preview the results of the operation without performing any action"
# client, workspace @TODO: -Fs (only in -f), -c (only in -S stream)
for a in 'client' 'workspace'
__fish_p4_register_command_option $a -x -a '(__fish_print_p4_workspaces)'
__fish_p4_register_command_option $a -s f -d "Allows the last modification date, which is normally read-only, to be set"
__fish_p4_register_command_option $a -s d -f -a '(__fish_print_p4_workspaces)' -d "Delete the specified client workspace whether or not the workspace is owned by the user"
# __fish_p4_register_command_option $a -a '-Fs' -d 'Deletes client with shelves (must follow -f)'
__fish_p4_register_command_option $a -s F -a 's' -d 'Deletes client with shelves (must follow -f)'
__fish_p4_register_command_option $a -s o -d "Write the client workspace spec to standard output"
__fish_p4_register_command_option $a -s i -d "Read the client workspace spec from standard input"
__fish_p4_register_command_option $a -s c -x -a '(__fish_print_p4_workspace_changelists)' -d "When used with -S stream, displays the workspace spec that would have been created for a stream at the moment the change was submitted"
__fish_p4_register_command_option $a -s s -d "Switch workspace view"
__fish_p4_register_command_option $a -s t -x -d "Specify a client workspace Template"
__fish_p4_register_command_option $a -l serverid -x -d "Forcefully delete workspace that is bound to another server"
__fish_p4_register_command_option $a -s S -x -a '(__fish_print_p4_streams)' -d "Associates the workspace with the specified stream"
end
# clients, workspaces @TODO -U and others are mutually exclusive
for a in 'clients' 'workspaces'
__fish_p4_register_command_option $a -s a -d "List all client workspaces, not just workspaces bound to this server"
__fish_p4_register_command_option $a -s e -x -d "List only client workspaces matching filter (case-sensitive)"
__fish_p4_register_command_option $a -s E -x -d "List only client workspaces matching filter (case-insensitive)"
__fish_p4_register_command_option $a -s m -x -d "List only the first max client workspaces"
__fish_p4_register_command_option $a -s s -x -d "List only client workspaces bound to the specified serverID. On an edge server, the -s option defaults to the edge server’s serverID"
__fish_p4_register_command_option $a -s S -x -a '(__fish_print_p4_streams)' -d "List client workspaces associated with the specified stream"
__fish_p4_register_command_option $a -s t -d "Display the time as well as the date of the last update to the workspace"
__fish_p4_register_command_option $a -s u -x -a '(__fish_print_p4_users)' -d "List only client workspaces owned by user"
__fish_p4_register_command_option $a -s U -d "List only client workspaces unloaded with p4 unload"
end
# flush @TODO
# have @TODO
# ignores @TODO
# sync @TODO --parallel has unique key-value pair syntax: --parallel=optq1=n,opt2=n,opt3=n,opt4=n
__fish_p4_register_command_option sync -s f -d "Force sync, overwrite all unopened files"
__fish_p4_register_command_option sync -s k -d "Keep existing workspace files, alias for p4 flush"
__fish_p4_register_command_option sync -s L -d "perform the sync on a list of valid file arguments in full depot syntax with a valid revision number"
__fish_p4_register_command_option sync -s m -x -d "Sync only the first max files specified"
__fish_p4_register_command_option sync -s n -d "Preview mode: Display the results of the sync without actually syncing"
__fish_p4_register_command_option sync -s N -d "Preview mode: Display network traffic estimates, don't actually sync"
__fish_p4_register_command_option sync -s p -d "Populate a client workspace, but do not update the have list"
__fish_p4_register_command_option sync -l parallel -x -a '(__fish_print_p4_parallel_options)' -d "Specify options for parallel file transfer"
__fish_p4_register_command_option sync -s q -d "Quiet operation: suppress normal output messages"
__fish_p4_register_command_option sync -s r -d "Reopen files that are mapped to new locations in the depot, in the new location"
__fish_p4_register_command_option sync -s s -d "Safe sync: Compare the content in your client workspace against what was last synced"
# update @TODO
# where @TODO
#-----------------------------------------------------
#--> Files
#-----------------------------------------------------
# add
__fish_p4_register_command_option add -s c -x -a '(__fish_print_p4_pending_changelists default)' -d "Changelist number"
__fish_p4_register_command_option add -s d -d "Revert and re-add"
__fish_p4_register_command_option add -s f -d "Use wildcard characters for files"
__fish_p4_register_command_option add -s I -d "Do not use P4IGNORE"
__fish_p4_register_command_option add -s n -d "Preview operation, don't change files"
__fish_p4_register_command_option add -s t -x -a '(__fish_print_p4_file_types)' -d "File type"
# attribute @TODO
# copy @TODO
# delete @TODO
# diff @TODO
# diff2 @TODO
# dirs @TODO
# edit
__fish_p4_register_command_option edit -s c -x -a '(__fish_print_p4_pending_changelists default)' -d "Changelist number"
__fish_p4_register_command_option edit -s k -d "Keep existing workspace files; mark the file as open for edit even if the file is not in the client view"
__fish_p4_register_command_option edit -s n -d "Preview operation, don't change files"
__fish_p4_register_command_option edit -s t -x -a '(__fish_print_p4_file_types)' -d "File type"
# files @TODO
# fstat @TODO
# grep @TODO
# move @TODO
# lock @TODO
# print @TODO
# reconcile @TODO
# rename @TODO
# revert @TODO
# status @TODO
# sizes @TODO
# unlock @TODO
#-----------------------------------------------------
#--> Changelists
#-----------------------------------------------------
# change, changelist
for a in 'change' 'changelist'
__fish_p4_register_command_option $a -x -a '(__fish_print_p4_pending_changelists)'
__fish_p4_register_command_option $a -s s -d "Allows jobs to be assigned arbitrary status values on submission of the changelist, rather than the default status of closed"
__fish_p4_register_command_option $a -s f -d "Force operation (The -u and the -f options are mutually exclusive)"
__fish_p4_register_command_option $a -s u -d "Update a submitted changelist (The -u and the -f options are mutually exclusive)"
__fish_p4_register_command_option $a -s O -x -a '(__fish_print_p4_pending_changelists)' -d "Changelist number"
__fish_p4_register_command_option $a -s d -x -a '(__fish_print_p4_pending_changelists)' -d "Delete a changelist"
__fish_p4_register_command_option $a -s o -d "Writes the changelist spec to standard output"
__fish_p4_register_command_option $a -s i -d "Read the changelist spec from standard input"
__fish_p4_register_command_option $a -s t -x -a "restricted public" -d "Modifies the 'Type' of the change"
__fish_p4_register_command_option $a -s U -x -a '(__fish_print_p4_users)' -d "Changes the 'User' of the change"
end
# changes, changelists
for a in 'changes' 'changelists'
__fish_p4_register_command_option $a -s i -d "Include changelists that affected files that were integrated with the specified files"
__fish_p4_register_command_option $a -s t -d "Display the time as well as the date of each change"
__fish_p4_register_command_option $a -s l -d "List long output, with the full text of each changelist description"
__fish_p4_register_command_option $a -s L -d "List long output, with the full text of each changelist description truncated at 250 characters"
__fish_p4_register_command_option $a -s f -d "View restricted changes (requires admin permission)"
__fish_p4_register_command_option $a -c c -x -a '(__fish_print_p4_workspace_changelists)' -d "List only changes made from the named client workspace"
__fish_p4_register_command_option $a -c m -x -d "List only the highest numbered max changes"
__fish_p4_register_command_option $a -c s -x -a 'pending submitted shelved' -d "Limit the list to the changelists with the given status"
__fish_p4_register_command_option $a -c u -x -a '(__fish_print_p4_users)' -d "List only changes made from the named user"
end
# describe @TODO: -dc<n>, -du<n>
__fish_p4_register_command_option describe -x -a '(__fish_print_p4_workspace_changelists)'
__fish_p4_register_command_option describe -s f -d 'Force the display of descriptions for restricted changelists'
__fish_p4_register_command_option describe -s O -d 'Specify the original changelist number'
__fish_p4_register_command_option describe -s s -d 'Short output without diffs'
__fish_p4_register_command_option describe -s S -d 'Display shelved files with diffs'
__fish_p4_register_command_option describe -s d -x -a '(__fish_print_p4_diff_options)' -d 'Diff'
# filelog @TODO
# opened
__fish_p4_register_command_option opened -s a -d "List opened files in all client workspaces"
__fish_p4_register_command_option opened -s c -x -a '(__fish_print_p4_pending_changelists default)' -d "List the files in a pending changelist"
__fish_p4_register_command_option opened -s C -x -a '(__fish_print_p4_workspaces)' -d "List only files that are open in the specified client workspace"
__fish_p4_register_command_option opened -s m -x -d "List only the first max open files"
__fish_p4_register_command_option opened -s s -d "Short output; do not output the revision number or file type"
__fish_p4_register_command_option opened -s u -x -a '(__fish_print_p4_users)' -d "List only those files that were opened by user"
__fish_p4_register_command_option opened -s x -d "List all files that have the +l filetype over all servers"
# reopen
__fish_p4_register_command_option reopen -x -a '(__fish_print_p4_opened_files)' -d "Select opened files"
__fish_p4_register_command_option reopen -s c -x -a '(__fish_print_p4_pending_changelists default)' -d "Move files to changelist"
__fish_p4_register_command_option reopen -s t -x -a '(__fish_print_p4_file_types)' -d "Change file type"
# review @TODO
# shelve
__fish_p4_register_command_option shelve -a '(__fish_print_p4_opened_files)'
__fish_p4_register_command_option shelve -s a -x -a 'submitunchanged leaveunchanged' -d "Options: 'submitunchanged' shelves all files, 'leaveunchanged' shelves only changed files"
__fish_p4_register_command_option shelve -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Changelist number"
__fish_p4_register_command_option shelve -s d -d 'Discard the shelved files'
__fish_p4_register_command_option shelve -s f -d 'Force overwrite of shelved files'
__fish_p4_register_command_option shelve -s i -d 'Read a changelist description from standard input'
__fish_p4_register_command_option shelve -s p -d "Promote a shelved change from an Edge server to a Commit server"
__fish_p4_register_command_option shelve -s r -d 'Replace all shelved files in the changelist with the files that are opened in your workspace'
# submit @TODO: parallel syntax
__fish_p4_register_command_option submit -a '(__fish_print_p4_opened_files)'
__fish_p4_register_command_option submit -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Submit specific changelist"
__fish_p4_register_command_option submit -s d -x -d "Immediately submit the changelist with supplied description and bypass the interactive form"
__fish_p4_register_command_option submit -s e -x -a '(__fish_print_p4_shelved_changelists)' -d "Submit specific shelved changelist"
__fish_p4_register_command_option submit -s f -x -a '(__fish_print_p4_submit_options)' -d "Override the SubmitOptions setting in the p4 client form"
__fish_p4_register_command_option submit -s i -d "Read a changelist specification from standard input"
__fish_p4_register_command_option submit -l noretransfer -x -a '(__fish_print_p4_noretransfer_options)'
__fish_p4_register_command_option submit -l parallel -x -a '(__fish_print_p4_parallel_options "submit")' -d "Specify options for parallel file transfer"
__fish_p4_register_command_option submit -s r -d "Reopen files for edit in the default changelist after submission"
__fish_p4_register_command_option submit -s s -d "Allows jobs to be assigned arbitrary status values on submission of the changelist"
# unshelve @TODO: Streams
__fish_p4_register_command_option unshelve -s b -x -a '(__fish_print_p4_branches)' -d "Specifies a branch spec for unshelving from"
__fish_p4_register_command_option unshelve -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Changelist number into which to unshelve"
__fish_p4_register_command_option unshelve -s f -d 'Force the overwriting of writable (but unopened) files'
__fish_p4_register_command_option unshelve -s n -d "Preview result of unshelve operation without restoring files to workspace"
__fish_p4_register_command_option unshelve -s P -x -a '(__fish_print_p4_streams)' -d "Unshelve to the specified parent stream"
__fish_p4_register_command_option unshelve -s s -x -a '(__fish_print_p4_shelved_changelists)' -d "Specify the source shelved pending changelist number"
__fish_p4_register_command_option unshelve -s S -x -a '(__fish_print_p4_streams)' -d "Specifies a stream spec for unshelving from"
#-----------------------------------------------------
#--> Jobs
#-----------------------------------------------------
# fix @TODO
# fixes @TODO
# job @TODO
# jobs @TODO
# jobspec @TODO
#-----------------------------------------------------
#--> Branching and Merging
#-----------------------------------------------------
# branch @TODO
# branches @TODO
# copy @TODO
# cstat @TODO
# integ, integrate @TODO -s fromFile is based on -b branchname, try resolving
for a in 'integ' 'integrate'
__fish_p4_register_command_option $a -s b -x -a '(__fish_print_p4_branches)' -d "Integrate the files using the sourceFile/targetFile mappings included in the branch view of branchname. If the toFiles argument is included, include only those target files in the branch view that match the pattern specified by toFiles"
__fish_p4_register_command_option $a -s n -d "Display the integrations this command would perform without actually performing them"
__fish_p4_register_command_option $a -s v -d "Open files for branching without copying toFiles into the client workspace"
__fish_p4_register_command_option $a -s c -x -a '(__fish_print_p4_pending_changelists)' -d "Open the toFiles for branch, integrate, or delete in the specified pending changelist"
__fish_p4_register_command_option $a -s q -d "Quiet mode"
__fish_p4_register_command_option $a -a '-Di' -d "f the source file has been deleted and re-added, revisions that precede the deletion will be considered to be part of the same source file"
__fish_p4_register_command_option $a -s f -d "Force the integration on all revisions of fromFile and toFile, even if some revisions have been integrated in the past"
__fish_p4_register_command_option $a -s h -d "Use the have revision"
__fish_p4_register_command_option $a -s O -x -a '(__fish_print_p4_integrate_output_options)' -d "Specify output options"
__fish_p4_register_command_option $a -s m -x -d "Limit the command to integrating only the first N files"
__fish_p4_register_command_option $a -s R -x -a '(__fish_print_p4_integrate_resolve_options)' -d "Specify resolve options"
__fish_p4_register_command_option $a -s s -r -d "Source file and revision"
__fish_p4_register_command_option $a -s r -r -d "Reverse the mappings in the branch view, integrating from the target files to the source files"
__fish_p4_register_command_option $a -s S -x -a '(__fish_print_p4_streams)' -d "Source stream"
__fish_p4_register_command_option $a -s P -x -a '(__fish_print_p4_streams)' -d "Custom parent stream"
end
# integrated @TODO
# interchanges @TODO
# istat @TODO
# label @TODO
# labels @TODO
# labelsync @TODO
# list @TODO
# merge @TODO
# populate @TODO
# tag @TODO
# resolve
__fish_p4_register_command_option resolve -s a -x -a '(__fish_print_p4_resolve_options a)' -d "Resolve automatically"
__fish_p4_register_command_option resolve -s A -x -a '(__fish_print_p4_resolve_options A)' -d "Constrain the type of resolve to branching, deletion, file type change, or move/rename"
__fish_p4_register_command_option resolve -s d -x -a '(__fish_print_p4_resolve_options d)' -d "Ignore specified differences in whitespace or line-ending convention"
__fish_p4_register_command_option resolve -s f -d "Allow already resolved, but not yet submitted, files to be resolved again"
__fish_p4_register_command_option resolve -s n -d "List the files that need resolving without actually performing the resolve"
__fish_p4_register_command_option resolve -s N -d "Preview the operation with additional information about any non-content resolve actions that are scheduled"
__fish_p4_register_command_option resolve -s o -d "Output the base file name and revision to be used during the resolve"
__fish_p4_register_command_option resolve -s t -d "Force a three-way merge, even on binary (non-text) files"
__fish_p4_register_command_option resolve -s v -d "Include conflict markers in the file for all changes between yours and base, and between theirs and base"
__fish_p4_register_command_option resolve -s c -x -a '(__fish_print_p4_workspace_changelists)' -d "Limit the scope of the resolve operation to the files opened in the specified changelist number"
# resolved @TODO
# stream @TODO
# streams @TODO
#-----------------------------------------------------
#--> Administration
#-----------------------------------------------------
# admin @TODO
# archive @TODO
# cachepurge @TODO
# configure @TODO
# counter @TODO
# counters @TODO
# dbschema @TODO
# dbstat @TODO
# depot @TODO
# depots @TODO
# diskspace @TODO
# journals @TODO
# key @TODO
# keys @TODO
# license @TODO
# lockstat @TODO
# logappend @TODO
# logger @TODO
# logparse @TODO
# logrotate @TODO
# logschema @TODO
# logstat @TODO
# logtail @TODO
# monitor @TODO
# obliterate @TODO
# ping @TODO
# property @TODO
# proxy @TODO
# pull @TODO
# reload @TODO
# renameuser @TODO
# replicate @TODO
# restore @TODO
# reviews @TODO
# server @TODO
# serverid @TODO
# servers @TODO
# triggers @TODO
# typemap @TODO
# unload @TODO
# verify @TODO
#-----------------------------------------------------
#--> Security
#-----------------------------------------------------
# group @TODO
# groups @TODO
# login @TODO
# logout @TODO
# passwd @TODO
# protect @TODO
# protects @TODO
# tickets @TODO
# trust @TODO
# user @TODO
# users @TODO
#-----------------------------------------------------
#--> Environment
#-----------------------------------------------------
# set
__fish_p4_register_command_option set -x -a '(__fish_print_p4_env_vars)'
__fish_p4_register_command_option set -s q -d "Reduce the output"
__fish_p4_register_command_option set -s s -d "Set the value of the registry variable for the local machine"
__fish_p4_register_command_option set -s S -x -d "Set the value of the registry variables as used by the service"

View File

@ -1,14 +1,61 @@
function __fish_complete_screen --description "Print a list of running screen sessions"
screen -list | __fish_sgrep \^\t.\*\(.\*\)|sed -e 's/\t\(.*\)\t(\(.*\))/\1'\t'Screen: \2/'
function __fish_detect_screen_socket_dir --description "Detect which folder screen uses"
set screen_bin screen
if not set -q __fish_screen_socket_dir
set -g __fish_screen_socket_dir (eval $screen_bin -ls __fish_i_don_t_think_this_will_be_matched | string match -r "(?<=No Sockets found in ).*(?=\.)")
end
end
function __fish_complete_screen_general_list_mac --description "Get the socket list on mac"
pushd $__fish_screen_socket_dir > /dev/null
set -l sockets (ls)
if test (count $sockets) -ne 0
switch $argv
case "Detached"
stat -f "%Lp %SB %N" -t "%D %T" $sockets | string match -r '^6\d{2} .*$' | string replace -r '^6\d{2} (\S+ \S+) (\S+)' '$2\t$1 Detached'
case "Attached"
stat -f "%Lp %SB %N" -t "%D %T" $sockets | string match -r '^7\d{2} .*$' | string replace -r '^7\d{2} (\S+ \S+) (\S+)' '$2\t$1 Attached'
end
end
popd > /dev/null
end
function __fish_complete_screen_general_list --description "Get the socket list"
screen -list | string match -r '^\t.*\(.*\)\s*\('$argv'\)\s*$'| string replace -r '\t(.*)\s+\((.*)\)\s*\((.*)\)' '$1\t$2 $3'
end
function __fish_complete_screen_detached --description "Print a list of detached screen sessions"
switch (uname)
case Darwin
__fish_complete_screen_general_list_mac Detached
case '*'
__fish_complete_screen_general_list Detached
end
end
function __fish_complete_screen_attached --description "Print a list of attached screen sessions"
switch (uname)
case Darwin
__fish_complete_screen_general_list_mac Attached
case '*'
__fish_complete_screen_general_list Attached
end
end
function __fish_complete_screen --description "Print a list of running screen sessions"
string join \n (__fish_complete_screen_attached) (__fish_complete_screen_detached)
end
# detect socket directory for mac users
__fish_detect_screen_socket_dir
complete -c screen -x
complete -c screen -s a -d 'Include all capabilitys'
complete -c screen -s A -d 'Adapt window size'
complete -c screen -s c -r -d 'Specify init file'
complete -c screen -s d -d 'Detach screen' -a '(__fish_complete_screen)'
complete -c screen -s D -d 'Detach screen' -a '(__fish_complete_screen)'
complete -c screen -s r -d 'Reattach session' -a '(__fish_complete_screen)'
complete -c screen -s d -d 'Detach screen' -a '(__fish_complete_screen)' -x
complete -c screen -s D -d 'Detach screen' -a '(__fish_complete_screen)' -x
complete -c screen -s r -d 'Reattach session' -a '(__fish_complete_screen)' -x
complete -c screen -s R -d 'Reattach/create session'
complete -c screen -o RR -d 'Reattach/create any session'
complete -c screen -s e -x -d 'Escape character'
@ -32,6 +79,6 @@ complete -c screen -s t -x -d 'Session title'
complete -c screen -s U -d 'UTF-8 mode'
complete -c screen -s v -d 'Display version and exit'
complete -c screen -o wipe -d 'Wipe dead sessions'
complete -c screen -s x -d 'Multi attach'
complete -c screen -s x -d 'Multi attach' -a '(__fish_complete_screen_attached)' -x
complete -c screen -s X -r -d 'Send command'

View File

@ -3,22 +3,23 @@
# -wn : Set the default window size to n
# +command : same as -c command
# Check if vi is really vim
if vi --version > /dev/null ^ /dev/null
complete -c vi -w vim
else
complete -c vi -s s --description 'Suppress all interactive user feedback'
complete -c vi -s C --description 'Encrypt/decrypt text'
complete -c vi -s l --description 'Set up for editing LISP programs'
complete -c vi -s L --description 'List saved file names after crash'
complete -c vi -s R --description 'Read-only mode'
complete -c vi -s S --description 'Use linear search for tags if tag file not sorted'
complete -c vi -s v --description 'Start in display editing state'
complete -c vi -s V --description 'Verbose mode'
complete -c vi -s x --description 'Encrypt/decrypt text'
complete -c vi -r -s r --description 'Recover file after crash'
complete -c vi -r -s t --description 'Edit the file containing a tag'
complete -c vi -r -c t --description 'Begin editing by executing the specified editor command'
# Check if vi exists at all ( needed for vi --version )
if type -q vi
# Check if vi is really vim
if vi --version > /dev/null ^ /dev/null
complete -c vi -w vim
else
complete -c vi -s s --description 'Suppress all interactive user feedback'
complete -c vi -s C --description 'Encrypt/decrypt text'
complete -c vi -s l --description 'Set up for editing LISP programs'
complete -c vi -s L --description 'List saved file names after crash'
complete -c vi -s R --description 'Read-only mode'
complete -c vi -s S --description 'Use linear search for tags if tag file not sorted'
complete -c vi -s v --description 'Start in display editing state'
complete -c vi -s V --description 'Verbose mode'
complete -c vi -s x --description 'Encrypt/decrypt text'
complete -c vi -r -s r --description 'Recover file after crash'
complete -c vi -r -s t --description 'Edit the file containing a tag'
complete -c vi -r -c t --description 'Begin editing by executing the specified editor command'
end
end

View File

@ -9,7 +9,11 @@ function __fish_cancel_commandline
#
# Set reverse fg/bg color mode, output ^C, restore normal mode, clear to EOL (to erase any
# autosuggestion).
echo -n (tput smso)"^C"(tput rmso)(tput el)
if command -v tput >/dev/null
echo -ns (tput smso; or tput so) "^C" (tput rmso; or tput se) (tput el; or tput ce)
else
echo -n "^C"
end
for i in (seq (commandline -L))
echo ""
end

View File

@ -310,7 +310,7 @@ function __fish_config_interactive -d "Initializations that should be performed
# Don't allow setting color other than what linux offers (see #2001)
functions -e set_color
function set_color --shadow-builtin
function set_color
set -l term_colors black red green yellow blue magenta cyan white normal
for a in $argv
if not contains -- $a $term_colors

View File

@ -475,14 +475,16 @@ function __fish_git_prompt_informative_status
set -l changedFiles (command git diff --name-status | cut -c 1-2)
set -l stagedFiles (command git diff --staged --name-status | cut -c 1-2)
set -l dirtystate (math (count $changedFiles) - (count (echo $changedFiles | grep "U")))
set -l dirtystate (math (count $changedFiles) - (count (echo $changedFiles | grep "U")) ^/dev/null)
set -l invalidstate (count (echo $stagedFiles | grep "U"))
set -l stagedstate (math (count $stagedFiles) - $invalidstate)
set -l stagedstate (math (count $stagedFiles) - $invalidstate ^/dev/null)
set -l untrackedfiles (command git ls-files --others --exclude-standard | wc -l | string trim)
set -l info
if [ (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles) = 0 ]
# If `math` fails for some reason, assume the state is clean - it's the simpler path
set -l state (math $dirtystate + $invalidstate + $stagedstate + $untrackedfiles ^/dev/null)
if test -z "$state"; or test "$state" = 0
set info $___fish_git_prompt_color_cleanstate$___fish_git_prompt_char_cleanstate$___fish_git_prompt_color_cleanstate_done
else
for i in $___fish_git_prompt_status_order

View File

@ -20,9 +20,6 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind $argv \cv fish_clipboard_paste
bind $argv \e cancel
bind $argv \cy yank
bind $argv \ey yank-pop
bind $argv \t complete
# shift-tab does a tab complete followed by a search.
bind $argv --key btab complete-and-search
@ -74,6 +71,9 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind $argv \cc __fish_cancel_commandline
bind $argv \cu backward-kill-line
bind $argv \cw backward-kill-path-component
bind $argv \e\[F end-of-line
bind $argv \e\[H beginning-of-line
bind $argv \ed 'set -l cmd (commandline); if test -z "$cmd"; echo; dirh; commandline -f repaint; else; commandline -f kill-word; end'
bind $argv \cd delete-or-exit

View File

@ -40,9 +40,9 @@ function alias --description 'Legacy function for creating shellscript functions
end
# Extract the first command from the body
# This is supposed to replace all non-escaped (i.e. preceded by an odd number of `\`) spaces with a newline
# so it splits on them
set -l tmp (string replace -ra "([^\\\ ])((\\\\\\\)*) " '$1\n' $body)
# This is supposed to replace all non-escaped (i.e. preceded by an odd number of `\`) spaces with a newline
# so it splits on them
set -l tmp (string replace -ra "([^\\\ ])((\\\\\\\)*) " '$1\n' $body)
set first_word (string trim $tmp[1])
if set -q tmp[2]
set body $tmp[2..-1]
@ -60,6 +60,5 @@ function alias --description 'Legacy function for creating shellscript functions
set prefix command
end
end
eval "function $name --wraps $first_word; $prefix $first_word $body \$argv; end"
echo "function $name --wraps $first_word; $prefix $first_word $body \$argv; end" | source
end

View File

@ -1,7 +1,7 @@
#
# Wrap the builtin cd command to maintain directory history.
#
function cd --shadow-builtin --description "Change directory"
function cd --description "Change directory"
set -l MAX_DIR_HIST 25
if test (count $argv) -gt 1

View File

@ -9,7 +9,9 @@ function dirh --description "Print the current directory history (the prev and n
set -l dirc (count $dirprev)
set -l dirprev_rev $dirprev[-1..1]
for i in (seq $dirc -1 1)
# This can't be (seq $dirc -1 1) because of BSD.
set -l dirnum (seq 1 $dirc)
for i in $dirnum[-1..1]
printf '%2d) %s\n' $i $dirprev_rev[$i]
end

View File

@ -1,18 +1,18 @@
function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fish"
if not set -q argv[1]
# Clear earlier bindings, if any
bind --erase --all
if test "$fish_key_bindings" != "fish_default_key_bindings"
# Allow the user to set the variable universally
set -q fish_key_bindings; or set -g fish_key_bindings
set fish_key_bindings fish_default_key_bindings # This triggers the handler, which calls us again and ensures the user_key_bindings are executed
return
end
# Clear earlier bindings, if any
bind --erase --all
end
# These are shell-specific bindings that we share with vi mode.
__fish_shared_key_bindings
__fish_shared_key_bindings $argv
# This is the default binding, i.e. the one used if no other binding matches
bind $argv "" self-insert
@ -33,9 +33,6 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
bind $argv -k backspace backward-delete-char
bind $argv \x7f backward-delete-char
bind $argv \e\[H beginning-of-line
bind $argv \e\[F end-of-line
# for PuTTY
# https://github.com/fish-shell/fish-shell/issues/180
bind $argv \e\[1~ beginning-of-line
@ -74,9 +71,6 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
bind \ed forward-kill-word
bind \ed kill-word
# escape cancels stuff
bind \e cancel
# Ignore some known-bad control sequences
# https://github.com/fish-shell/fish-shell/issues/1917
bind \e\[I 'begin;end'

View File

@ -1,4 +1,11 @@
function fish_vi_cursor -d 'Set cursor shape for different vi modes'
# Since we read exported variables (KONSOLE_PROFILE_NAME and ITERM_PROFILE)
# we need to check harder if we're actually in a supported terminal,
# because we might be in a term-in-a-term (emacs ansi-term).
if not contains -- $TERM xterm konsole xterm-256color konsole-256color
and not set -q TMUX
return
end
set -l terminal $argv[1]
set -q terminal[1]
or set terminal auto
@ -37,7 +44,7 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes'
or set -g fish_cursor_unknown block blink
echo "
function fish_vi_cursor_handle --on-variable fish_bind_mode
function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec
set -l varname fish_cursor_\$fish_bind_mode
if not set -q \$varname
set varname fish_cursor_unknown
@ -47,5 +54,17 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes'
$tmux_postfix
end
" | source
echo "
function fish_vi_cursor_handle_preexec --on-event fish_preexec
set -l varname fish_cursor_default
if not set -q \$varname
set varname fish_cursor_unknown
end
$tmux_prefix
$function \$\$varname
$tmux_postfix
end
" | source
end

View File

@ -1,32 +1,45 @@
function fish_vi_key_bindings --description 'vi-like key bindings for fish'
# Allow any argument to skip setting the variable.
if not set -q argv[1]
# Allow just calling this function to correctly set the bindings.
# Because it's a rather discoverable name, users will execute it
# and without this would then have subtly broken bindings.
if test "$fish_key_bindings" != "fish_vi_key_bindings"
# Allow the user to set the variable universally
set -q fish_key_bindings
or set -g fish_key_bindings
set fish_key_bindings fish_vi_key_bindings # This triggers the handler, which calls us again and ensures the user_key_bindings are executed
return
end
# Erase all bindings if not explicitly requested otherwise to
# allow for hybrid bindings.
# This needs to be checked here because if we are called again
# via the variable handler the argument will be gone.
if not contains -- $argv[1] --no-erase
bind --erase --all
else if set -q argv[1]
set -e argv[1]
end
# Allow just calling this function to correctly set the bindings.
# Because it's a rather discoverable name, users will execute it
# and without this would then have subtly broken bindings.
if test "$fish_key_bindings" != "fish_vi_key_bindings"
# Allow the user to set the variable universally
set -q fish_key_bindings
or set -g fish_key_bindings
set fish_key_bindings fish_vi_key_bindings # This triggers the handler, which calls us again and ensures the user_key_bindings are executed
return
end
# The default escape timeout is 300ms. But for users of Vi bindings that can be slightly
# annoying when trying to switch to Vi "normal" mode. So set a shorter timeout in this case
# unless the user has explicitly set the delay.
set -q fish_escape_delay_ms; or set -g fish_escape_delay_ms 100
set -l init_mode insert
set -l eol_keys \$ g\$ \e\[F
set -l bol_keys \^ 0 g\^ \e\[H
if set -q argv[1]
# These are only the special vi-style keys
# not end/home, we share those.
set -l eol_keys \$ g\$
set -l bol_keys \^ 0 g\^
if contains -- $argv[1] insert default visual
set init_mode $argv[1]
else if set -q argv[1]
# We should still go on so the bindings still get set.
echo "Unknown argument $argv" >&2
end
# Inherit shared key bindings.
# Do this first so vi-bindings win over default.
bind --erase --all
for mode in insert default visual
__fish_shared_key_bindings -M $mode
end
@ -76,13 +89,6 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
bind k up-or-search
bind j down-or-search
bind \e\[A up-or-search
bind \e\[B down-or-search
bind -k down down-or-search
bind -k up up-or-search
bind \eOA up-or-search
bind \eOB down-or-search
bind b backward-word
bind B backward-bigword
bind ge backward-word
@ -220,10 +226,16 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
bind -M visual -m default \cc end-selection force-repaint
bind -M visual -m default \e end-selection force-repaint
set fish_bind_mode $init_mode
# Make it easy to turn an unexecuted command into a comment in the shell history. Also, remove
# the commenting chars so the command can be further edited then executed.
bind -M default \# __fish_toggle_comment_commandline
bind -M visual \# __fish_toggle_comment_commandline
# Set the cursor shape
# After executing once, this will have defined functions listening for the variable.
# Therefore it needs to be before setting fish_bind_mode.
fish_vi_cursor
set fish_bind_mode $init_mode
end

View File

@ -1,7 +1,7 @@
#
# Wrap the builtin history command to provide additional functionality.
#
function history --shadow-builtin --description "display or manipulate interactive command history"
function history --description "display or manipulate interactive command history"
set -l cmd
set -l search_mode
set -l with_time
@ -40,7 +40,7 @@ function history --shadow-builtin --description "display or manipulate interacti
end
if not set -q cmd[1]
set cmd search # default to "search" if the user didn't explicitly specify a command
set cmd search # default to "search" if the user didn't explicitly specify a command
else if set -q cmd[2]
printf (_ "You cannot specify multiple commands: %s\n") "$cmd"
return 1
@ -60,10 +60,10 @@ function history --shadow-builtin --description "display or manipulate interacti
builtin history --search $search_mode $with_time -- $argv
end
case delete # Interactively delete history
case delete # Interactively delete history
# TODO: Fix this to deal with history entries that have multiple lines.
if not set -q argv[1]
printf (_ "You must specify at least one search term when deleting entries") >&2
printf (_ "You must specify at least one search term when deleting entries\n") >&2
return 1
end
@ -105,8 +105,8 @@ function history --shadow-builtin --description "display or manipulate interacti
for i in (string split " " -- $choice)
if test -z "$i"
or not string match -qr '^[1-9][0-9]*$' -- $i
or test $i -gt $found_items_count
or not string match -qr '^[1-9][0-9]*$' -- $i
or test $i -gt $found_items_count
printf "Ignoring invalid history entry ID \"%s\"\n" $i
continue
end
@ -118,9 +118,19 @@ function history --shadow-builtin --description "display or manipulate interacti
end
case save
if test -n "$search_mode"
or test -n "$with_time"
printf (_ "history: you cannot use any options with %s command\n") save >&2
return 1
end
builtin history --save -- $argv
case merge
if test -n "$search_mode"
or test -n "$with_time"
printf (_ "history: you cannot use any options with %s command\n") merge >&2
return 1
end
builtin history --merge -- $argv
case help
@ -128,11 +138,19 @@ function history --shadow-builtin --description "display or manipulate interacti
case clear
# Erase the entire history.
read --local --prompt "echo 'Are you sure you want to clear history? (y/n) '" choice
if test "$choice" = "y"
or test "$choice" = "yes"
if test -n "$search_mode"
or test -n "$with_time"
printf (_ "history: you cannot use any options with %s command\n") clear >&2
return 1
end
printf (_ "If you enter 'yes' your entire interactive command history will be erased\n")
read --local --prompt "echo 'Are you sure you want to clear history? (yes/no) '" choice
if test "$choice" = "yes"
builtin history --clear -- $argv
and echo "History cleared!"
and printf (_ "Command history cleared!")
else
printf (_ "You did not say 'yes' so I will not clear your command history\n")
end
end
end

View File

@ -1,4 +1,3 @@
function pushd --description 'Push directory to stack'
if count $argv >/dev/null
# check for --help
@ -9,8 +8,13 @@ function pushd --description 'Push directory to stack'
end
# emulate bash by checking if argument of form +n or -n
set rot_l (echo $argv[1] | sed -n '/^+\([0-9]\)$/ s//\1/g p')
set rot_r (echo $argv[1] | sed -n '/^-\([0-9]\)$/ s//\1/g p')
set -l rot_r
set -l rot_l
if string match -qr '^-[0-9]+$' -- $argv[1]
set rot_r (string sub -s 2 -- $argv[1])
else if string match -qr '^\+[0-9]+$' -- $argv[1]
set rot_l (string sub -s 2 -- $argv[1])
end
end
# emulate bash: an empty pushd should switch the top of dirs
@ -39,7 +43,7 @@ function pushd --description 'Push directory to stack'
# translate a right rotation to a left rotation
if test -n "$rot_r"
# check the rotation in range
if test $rot_r -gt (math (count $stack) - 1)
if test $rot_r -ge (count $stack)
echo "pushd: -$rot_r: directory stack index out of range"
return 1
end
@ -48,7 +52,7 @@ function pushd --description 'Push directory to stack'
end
# check the rotation in range
if test $rot_l -gt (math (count $stack) - 1)
if test $rot_l -ge (count $stack)
echo "pushd: +$rot_l: directory stack index out of range"
return 1
else
@ -67,8 +71,7 @@ function pushd --description 'Push directory to stack'
return
end
# Comment to avoid set completions
# argv[1] is a directory
set -g dirstack (command pwd) $dirstack
cd $argv[1]
end

View File

@ -220,6 +220,11 @@ body {
word-wrap: break-word;
}
.raw_binding {
padding-left: 20px;
font-family: monospace;
}
.history_text {
padding-top: 5px;
padding-bottom: 5px;

View File

@ -25,8 +25,16 @@ filters.filter("filterBinding", function() {
for(i=0; i<bindings.length; ++i) {
binding = bindings[i];
if (binding.command.indexOf(query) != -1 || binding.readable_binding.toLowerCase().indexOf(query.toLowerCase()) != -1) {
if (binding.command.indexOf(query) != -1) {
result.push(binding);
continue;
}
varieties = binding.bindings;
for (j=0; j<varieties.length; ++j) {
if (varieties[j].readable_binding.toLowerCase().indexOf(query.toLowerCase()) != -1) {
result.push(binding);
break;
}
}
}

View File

@ -6,8 +6,13 @@
<tbody>
<tr class="data_table_row" ng-repeat="binding in bindings | filterBinding:query">
<td ng-class="{ data_table_cell: true, no_overflow: !binding._is_selected }" style="text-align: right; padding-right: 30px;" ng-click="binding._is_selected = !binding._is_selected">{{ binding.command }}</td>
<!-- Some bindings are listed multiple times for e.g. function backward-char is bound to \e\[D as well as key left. Users may want to know why some bindings are listed twice, so the actual binding is shown in next line on a click -->
<td ng-class="{ data_table_cell: true, no_overflow: !binding._is_selected }" style="text-align: left; padding-right: 30px;" ng-click="binding._is_selected = !binding._is_selected">{{ binding.readable_binding }} <div ng-show="binding._is_selected"> {{ binding.binding }} </div> </td>
<!-- Raw binding commands are shown in next line on a click -->
<td ng-class="{ data_table_cell: true, no_overflow: !binding._is_selected }" style="text-align: left; padding-right: 30px;" ng-click="binding._is_selected = !binding._is_selected">
<div ng-repeat="variety in binding.bindings">
{{ variety.readable_binding }}
<div class="raw_binding" ng-repeat="raw in variety.raw_bindings" ng-show="binding._is_selected" > {{ raw }} </div>
</div>
</td>
</tr>
</tbody>
</table>

View File

@ -84,6 +84,8 @@ named_colors = {
'white' : 'FFFFFF'
}
bindings_blacklist = set(["self-insert", "'begin;end'"])
def parse_one_color(comp):
""" A basic function to parse a single color value like 'FFA000' """
if comp in named_colors:
@ -284,17 +286,23 @@ class FishVar:
class FishBinding:
"""A class that represents keyboard binding """
def __init__(self, command, binding, readable_binding, description=None):
def __init__(self, command, raw_binding, readable_binding, description=None):
self.command = command
self.binding = binding
self.readable_binding = readable_binding
self.bindings = []
self.description = description
self.add_binding(raw_binding, readable_binding)
def add_binding(self, raw_binding, readable_binding):
for i in self.bindings:
if i['readable_binding'] == readable_binding:
i['raw_bindings'].append(raw_binding)
break
else:
self.bindings.append({'readable_binding':readable_binding, 'raw_bindings':[raw_binding]})
def get_json_obj(self):
return {"command" : self.command, "binding": self.binding, "readable_binding": self.readable_binding, "description": self.description }
return {"command" : self.command, "bindings": self.bindings, "description": self.description}
def get_readable_binding(command):
return command
class BindingParser:
""" Class to parse codes for bind command """
@ -304,7 +312,8 @@ class BindingParser:
"sdc": "Shift Delete", "shome": "Shift Home",
"left": "Left Arrow", "right": "Right Arrow",
"up": "Up Arrow", "down": "Down Arrow",
"sleft": "Shift Left", "sright": "Shift Right"
"sleft": "Shift Left", "sright": "Shift Right",
"btab": "Shift Tab"
}
def set_buffer(self, buffer):
@ -343,8 +352,10 @@ class BindingParser:
# \[1\; is start of control sequence
if c == '1':
self.get_char();c = self.get_char()
if c == ";":
b = self.get_char(); c = self.get_char()
if b == '\\' and c == '~':
result += "Home"
elif c == ";":
c = self.get_char()
# 3 is Alt
@ -352,6 +363,12 @@ class BindingParser:
result += "ALT - "
c = self.get_char()
# \[4\~ is End
if c == '4':
b = self.get_char(); c = self.get_char()
if b == '\\' and c == '~':
result += "End"
# 5 is Ctrl
if c == '5':
result += "CTRL - "
@ -381,7 +398,7 @@ class BindingParser:
""" Gets a readable representation of binding """
try:
result = BindingParser.readable_keys[self.buffer]
result = BindingParser.readable_keys[self.buffer.lower()]
except KeyError:
result = self.parse_binding()
@ -422,14 +439,21 @@ class BindingParser:
result += 'Tab'
elif c == 'b':
result += 'Backspace'
elif c.isalpha():
result += '\\' + c
else:
result += c
elif c == '\x7f':
result += 'Backspace'
else:
result += c
if ctrl:
readable_command += 'CTRL - '
if alt:
readable_command += 'ALT - '
if result == '':
return 'unknown-control-sequence'
return readable_command + result
@ -564,6 +588,7 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
# Put all the bindings into a list
bindings = []
command_to_binding = {}
binding_parser = BindingParser()
for line in out.split('\n'):
@ -574,15 +599,23 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
if comps[1] == '-k':
key_name, command = comps[2].split(' ', 1)
binding_parser.set_buffer(key_name)
binding_parser.set_buffer(key_name.capitalize())
else:
key_name = None
command = comps[2]
binding_parser.set_buffer(comps[1])
if command in bindings_blacklist:
continue
readable_binding = binding_parser.get_readable_binding()
fish_binding = FishBinding(command, key_name, readable_binding)
bindings.append(fish_binding)
if command in command_to_binding:
fish_binding = command_to_binding[command]
fish_binding.add_binding(line, readable_binding)
else:
fish_binding = FishBinding(command, line, readable_binding)
bindings.append(fish_binding)
command_to_binding[command] = fish_binding
return [ binding.get_json_obj() for binding in bindings ]

View File

@ -919,10 +919,6 @@ static wcstring functions_def(const wcstring &name) {
out.append(esc_desc);
}
if (function_get_shadow_builtin(name)) {
out.append(L" --shadow-builtin");
}
if (!function_get_shadow_scope(name)) {
out.append(L" --no-scope-shadowing");
}
@ -1491,17 +1487,13 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
// Hackish const_cast matches the one in builtin_run.
const null_terminated_array_t<wchar_t> argv_array(args);
wchar_t **argv = const_cast<wchar_t **>(argv_array.get());
int argc = builtin_count_args(argv);
int res = STATUS_BUILTIN_OK;
wchar_t *desc = 0;
std::vector<event_t> events;
bool has_named_arguments = false;
wcstring_list_t named_arguments;
wcstring_list_t inherit_vars;
bool shadow_builtin = false;
bool shadow_scope = true;
wcstring_list_t wrap_targets;
@ -1522,7 +1514,6 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
{L"wraps", required_argument, 0, 'w'},
{L"help", no_argument, 0, 'h'},
{L"argument-names", no_argument, 0, 'a'},
{L"shadow-builtin", no_argument, 0, 'B'},
{L"no-scope-shadowing", no_argument, 0, 'S'},
{L"inherit-variable", required_argument, 0, 'V'},
{0, 0, 0, 0}};
@ -1531,7 +1522,7 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
int opt_index = 0;
// The leading - here specifies RETURN_IN_ORDER.
int opt = w.wgetopt_long(argc, argv, L"-d:s:j:p:v:e:w:haBSV:", long_options, &opt_index);
int opt = w.wgetopt_long(argc, argv, L"-d:s:j:p:v:e:w:haSV:", long_options, &opt_index);
if (opt == -1) break;
switch (opt) {
case 0: {
@ -1625,10 +1616,6 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
name_is_first_positional = !positionals.empty();
break;
}
case 'B': {
shadow_builtin = true;
break;
}
case 'S': {
shadow_scope = false;
break;
@ -1717,30 +1704,6 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
}
}
if (!res) {
bool function_name_shadows_builtin = false;
wcstring_list_t builtin_names = builtin_get_names();
for (size_t i = 0; i < builtin_names.size(); i++) {
const wchar_t *el = builtin_names.at(i).c_str();
if (el == function_name) {
function_name_shadows_builtin = true;
break;
}
}
if (function_name_shadows_builtin && !shadow_builtin) {
append_format(
*out_err,
_(L"%ls: function name shadows a builtin so you must use '--shadow-builtin'"),
argv[0]);
res = STATUS_BUILTIN_ERROR;
} else if (!function_name_shadows_builtin && shadow_builtin) {
append_format(*out_err, _(L"%ls: function name does not shadow a builtin so you "
L"must not use '--shadow-builtin'"),
argv[0]);
res = STATUS_BUILTIN_ERROR;
}
}
if (!res) {
// Here we actually define the function!
function_data_t d;
@ -1748,7 +1711,6 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
d.name = function_name;
if (desc) d.description = desc;
d.events.swap(events);
d.shadow_builtin = shadow_builtin;
d.shadow_scope = shadow_scope;
d.named_arguments.swap(named_arguments);
d.inherit_vars.swap(inherit_vars);
@ -2849,7 +2811,15 @@ static bool set_hist_cmd(wchar_t *const cmd, hist_cmd_t *hist_cmd, hist_cmd_t su
return true;
}
#define CHECK_FOR_UNEXPECTED_HIST_ARGS() \
#define CHECK_FOR_UNEXPECTED_HIST_OPTIONS(hist_cmd) \
if (history_search_type_defined || with_time) { \
streams.err.append_format(_(L"history: you cannot use any options with %ls command\n"), \
hist_cmd_to_string(hist_cmd).c_str()); \
status = STATUS_BUILTIN_ERROR; \
break; \
}
#define CHECK_FOR_UNEXPECTED_HIST_ARGS(hist_cmd) \
if (args.size() != 0) { \
streams.err.append_format(BUILTIN_ERR_ARG_COUNT, cmd, \
hist_cmd_to_string(hist_cmd).c_str(), 0, args.size()); \
@ -2860,7 +2830,6 @@ static bool set_hist_cmd(wchar_t *const cmd, hist_cmd_t *hist_cmd, hist_cmd_t su
/// Manipulate history of interactive commands executed by the user.
static int builtin_history(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
wchar_t *cmd = argv[0];
;
int argc = builtin_count_args(argv);
hist_cmd_t hist_cmd = HIST_NOOP;
history_search_type_t search_type = (history_search_type_t)-1;
@ -2990,23 +2959,26 @@ static int builtin_history(parser_t &parser, io_streams_t &streams, wchar_t **ar
break;
}
case HIST_CLEAR: {
CHECK_FOR_UNEXPECTED_HIST_ARGS();
CHECK_FOR_UNEXPECTED_HIST_OPTIONS(hist_cmd)
CHECK_FOR_UNEXPECTED_HIST_ARGS(hist_cmd)
history->clear();
history->save();
break;
}
case HIST_MERGE: {
CHECK_FOR_UNEXPECTED_HIST_ARGS();
CHECK_FOR_UNEXPECTED_HIST_OPTIONS(hist_cmd)
CHECK_FOR_UNEXPECTED_HIST_ARGS(hist_cmd)
history->incorporate_external_changes();
break;
}
case HIST_SAVE: {
CHECK_FOR_UNEXPECTED_HIST_ARGS();
CHECK_FOR_UNEXPECTED_HIST_OPTIONS(hist_cmd)
CHECK_FOR_UNEXPECTED_HIST_ARGS(hist_cmd)
history->save();
break;
}
default: {
DIE("Unhandled history command");
case HIST_NOOP: {
DIE("Unexpected HIST_NOOP seen");
break;
}
}
@ -3105,7 +3077,7 @@ static const builtin_data_t builtin_datas[] = {
{L"[", &builtin_test, N_(L"Test a condition")},
#if 0
// Disabled for the 2.2.0 release: https://github.com/fish-shell/fish-shell/issues/1809.
{ L"__fish_parse", &builtin_parse, N_(L"Try out the new parser") },
{ L"__fish_parse", &builtin_parse, N_(L"Try out the new parser") },
#endif
{L"and", &builtin_generic, N_(L"Execute command if previous command suceeded")},
{L"begin", &builtin_generic, N_(L"Create a block of code")},

View File

@ -264,11 +264,20 @@ uintmax_t raw_string_to_scalar_type(const wchar_t *s, wchar_t **end) {
template <>
long double raw_string_to_scalar_type(const wchar_t *s, wchar_t **end) {
// Forcing the locale to C is questionable but it's what the old C_STRTOD() that I inlined here
// as part of changing how locale management is done by fish.
char *old_locale = setlocale(LC_NUMERIC, "C");
double val = wcstod(s, end);
setlocale(LC_NUMERIC, old_locale);
if (**end == L'\0') return val;
// The conversion using the user's locale failed. That may be due to the string not being a
// valid floating point value. It could also be due to the locale using different separator
// characters than the normal english convention. So try again by forcing the use of a locale
// that employs the english convention for writing floating point numbers.
//
// TODO: switch to the wcstod_l() function to avoid changing the global locale.
char *saved_locale = strdup(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
val = wcstod(s, end);
setlocale(LC_NUMERIC, saved_locale);
free(saved_locale);
return val;
}

View File

@ -202,7 +202,7 @@ static complete_flags_t resolve_auto_space(const wcstring &comp, complete_flags_
return new_flags;
}
// completion_t functions. Note that the constructor resolves flags!
/// completion_t functions. Note that the constructor resolves flags!
completion_t::completion_t(const wcstring &comp, const wcstring &desc, string_fuzzy_match_t mat,
complete_flags_t flags_val)
: completion(comp), description(desc), match(mat), flags(resolve_auto_space(comp, flags_val)) {}
@ -374,7 +374,6 @@ void append_completion(std::vector<completion_t> *completions, const wcstring &c
// Nasty hack for #1241 - since the constructor needs the completion string to resolve
// AUTO_SPACE, and we aren't providing it with the completion, we have to do the resolution
// ourselves. We should get this resolving out of the constructor.
assert(completions != NULL);
const wcstring empty;
completions->push_back(completion_t(empty, empty, match, resolve_auto_space(comp, flags)));
@ -517,21 +516,31 @@ static void parse_cmd_string(const wcstring &str, wcstring &path, wcstring &cmd)
}
}
/// Copy any strings in possible_comp which have the specified prefix to the completer's completion
/// array. The prefix may contain wildcards. The output will consist of completion_t structs.
/// Copy any strings in possible_comp which have the specified prefix to the
/// completer's completion array. The prefix may contain wildcards. The output
/// will consist of completion_t structs.
///
/// There are three ways to specify descriptions for each completion. Firstly, if a description has
/// already been added to the completion, it is _not_ replaced. Secondly, if the desc_func function
/// is specified, use it to determine a dynamic completion. Thirdly, if none of the above are
/// available, the desc string is used as a description.
/// There are three ways to specify descriptions for each completion. Firstly,
/// if a description has already been added to the completion, it is _not_
/// replaced. Secondly, if the desc_func function is specified, use it to
/// determine a dynamic completion. Thirdly, if none of the above are available,
/// the desc string is used as a description.
///
/// \param wc_escaped the prefix, possibly containing wildcards. The wildcard should not have been
/// unescaped, i.e. '*' should be used for any string, not the ANY_STRING character.
/// \param desc the default description, used for completions with no embedded description. The
/// description _may_ contain a COMPLETE_SEP character, if not, one will be prefixed to it
/// \param desc_func the function that generates a description for those completions witout an
/// embedded description
/// \param possible_comp the list of possible completions to iterate over
/// @param wc_escaped
/// the prefix, possibly containing wildcards. The wildcard should not have
/// been unescaped, i.e. '*' should be used for any string, not the
/// ANY_STRING character.
/// @param desc
/// the default description, used for completions with no embedded
/// description. The description _may_ contain a COMPLETE_SEP character, if
/// not, one will be prefixed to it
/// @param desc_func
/// the function that generates a description for those completions witout an
/// embedded description
/// @param possible_comp
/// the list of possible completions to iterate over
/// @param flags
/// The flags
void completer_t::complete_strings(const wcstring &wc_escaped, const wchar_t *desc,
wcstring (*desc_func)(const wcstring &),
std::vector<completion_t> &possible_comp,
@ -1563,7 +1572,9 @@ static wrapper_map_t &wrap_map() {
return *wrapper_map;
}
/// Add a new target that is wrapped by command. Example: __fish_sgrep (command) wraps grep (target).
/// Add a new target that is wrapped by command. Example: __fish_sgrep (command) wraps grep
/// (target).
bool complete_add_wrapper(const wcstring &command, const wcstring &new_target) {
if (command.empty() || new_target.empty()) {
return false;

View File

@ -621,9 +621,10 @@ bool env_universal_t::open_and_acquire_lock(const wcstring &path, int *out_fd) {
continue;
}
#ifdef O_EXLOCK
else if (err == EOPNOTSUPP) {
else if (err == ENOTSUP || err == EOPNOTSUPP) {
// Filesystem probably does not support locking. Clear the flag and try again. Note
// that we try taking the lock via flock anyways.
// that we try taking the lock via flock anyways. Note that on Linux the two errno
// symbols have the same value but on BSD they're different.
flags &= ~O_EXLOCK;
needs_lock = true;
continue;
@ -931,7 +932,7 @@ static bool get_mac_address(unsigned char macaddr[MAC_ADDRESS_MAX_LEN],
if (getifaddrs(&ifap) == 0) {
for (const ifaddrs *p = ifap; p; p = p->ifa_next) {
if (p->ifa_addr->sa_family == AF_LINK) {
if (p->ifa_addr && p->ifa_addr->sa_family == AF_LINK) {
if (p->ifa_name && p->ifa_name[0] &&
!strcmp((const char *)p->ifa_name, interface)) {
const sockaddr_dl &sdl = *reinterpret_cast<sockaddr_dl *>(p->ifa_addr);
@ -1043,7 +1044,7 @@ class universal_notifier_shmem_poller_t : public universal_notifier_t {
// Memory map the region.
if (!errored) {
void *addr = mmap(NULL, sizeof(universal_notifier_shmem_t), PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, fd, 0);
MAP_SHARED, fd, 0);
if (addr == MAP_FAILED) {
int err = errno;
report_error(err, L"Unable to memory map shared memory object with path '%s'",

View File

@ -633,7 +633,6 @@ void exec_job(parser_t &parser, job_t *j) {
const wcstring func_name = p->argv0();
wcstring def;
bool function_exists = function_get_definition(func_name, &def);
bool shadow_scope = function_get_shadow_scope(func_name);
const std::map<wcstring, env_var_t> inherit_vars =
function_get_inherit_vars(func_name);

View File

@ -144,7 +144,6 @@ function_info_t::function_info_t(const function_data_t &data, const wchar_t *fil
named_arguments(data.named_arguments),
inherit_vars(snapshot_vars(data.inherit_vars)),
is_autoload(autoload),
shadow_builtin(data.shadow_builtin),
shadow_scope(data.shadow_scope) {}
function_info_t::function_info_t(const function_info_t &data, const wchar_t *filename,
@ -156,7 +155,6 @@ function_info_t::function_info_t(const function_info_t &data, const wchar_t *fil
named_arguments(data.named_arguments),
inherit_vars(data.inherit_vars),
is_autoload(autoload),
shadow_builtin(data.shadow_builtin),
shadow_scope(data.shadow_scope) {}
void function_add(const function_data_t &data, const parser_t &parser, int definition_line_offset) {
@ -260,12 +258,6 @@ std::map<wcstring, env_var_t> function_get_inherit_vars(const wcstring &name) {
return func ? func->inherit_vars : std::map<wcstring, env_var_t>();
}
int function_get_shadow_builtin(const wcstring &name) {
scoped_lock locker(functions_lock);
const function_info_t *func = function_get(name);
return func ? func->shadow_builtin : false;
}
int function_get_shadow_scope(const wcstring &name) {
scoped_lock locker(functions_lock);
const function_info_t *func = function_get(name);

View File

@ -32,8 +32,6 @@ struct function_data_t {
wcstring_list_t inherit_vars;
/// Set to true if invoking this function shadows the variables of the underlying function.
bool shadow_scope;
/// Set to true if this function shadows a builtin.
bool shadow_builtin;
};
class function_info_t {
@ -53,8 +51,6 @@ class function_info_t {
const std::map<wcstring, env_var_t> inherit_vars;
/// Flag for specifying that this function was automatically loaded.
const bool is_autoload;
/// Set to true if this function shadows a builtin.
const bool shadow_builtin;
/// Set to true if invoking this function shadows the variables of the underlying function.
const bool shadow_scope;
@ -129,9 +125,6 @@ std::map<wcstring, env_var_t> function_get_inherit_vars(const wcstring &name);
/// is successful.
bool function_copy(const wcstring &name, const wcstring &new_name);
/// Returns whether this function shadows a builtin of the same name.
int function_get_shadow_builtin(const wcstring &name);
/// Returns whether this function shadows variables of the underlying function.
int function_get_shadow_scope(const wcstring &name);

View File

@ -1402,9 +1402,9 @@ static bool format_history_record(const history_item_t &item, const bool with_ti
const time_t seconds = item.timestamp();
struct tm timestamp;
if (!localtime_r(&seconds, &timestamp)) return false;
char timestamp_string[22];
if (strftime(timestamp_string, 22, "%Y-%m-%d %H:%M:%S ", &timestamp) != 21) return false;
streams.out.append(str2wcstring(timestamp_string));
wchar_t timestamp_string[24];
if (std::wcsftime(timestamp_string, 23, L"# %Y-%m-%d %H:%M:%S\n", &timestamp) == 0) return false;
streams.out.append(timestamp_string);
}
streams.out.append(item.str());
streams.out.append(L"\n");

View File

@ -216,7 +216,10 @@ wcstring input_get_bind_mode() {
/// Set the current bind mode.
void input_set_bind_mode(const wcstring &bm) {
env_set(FISH_BIND_MODE_VAR, bm.c_str(), ENV_GLOBAL);
// Only set this if it differs to not execute variable handlers all the time.
if (input_get_bind_mode() != bm.c_str()) {
env_set(FISH_BIND_MODE_VAR, bm.c_str(), ENV_GLOBAL);
}
}
/// Returns the arity of a given input function.

View File

@ -514,7 +514,7 @@ void proc_fire_event(const wchar_t *msg, int type, pid_t pid, int status) {
event.arguments.resize(0);
}
int job_reap(bool interactive) {
int job_reap(bool allow_interactive) {
ASSERT_IS_MAIN_THREAD();
job_t *jnext;
int found = 0;
@ -527,6 +527,10 @@ int job_reap(bool interactive) {
}
locked = true;
// this may be invoked in an exit handler, after the TERM has been torn down
// don't try to print in that case (#3222)
const bool interactive = allow_interactive && cur_term != NULL;
process_mark_finished_children(false);
// Preserve the exit status.

View File

@ -1,8 +0,0 @@
function: function name shadows a builtin so you must use '--shadow-builtin'
fish: function pwd; end
^
yes, it failed as expected
function: function name does not shadow a builtin so you must not use '--shadow-builtin'
fish: function not_builtin --shadow-builtin; end
^
yes, it failed as expected

View File

@ -44,16 +44,3 @@ for i in (seq 4)
echo "Function name$i not found, but should have been"
end
end
# Test that we can't define a function that shadows a builtin by accident.
function pwd; end
or echo 'yes, it failed as expected' >&2
# Test that we can define a function that shadows a builtin if we use the
# right flag.
function pwd --shadow-builtin; end
and echo '"function pwd --shadow-builtin" worked'
# Using --shadow-builtin for a non-builtin function name also fails.
function not_builtin --shadow-builtin; end
or echo 'yes, it failed as expected' >&2

View File

@ -22,4 +22,3 @@ Function name1 found
Function name2 found
Function name3 found
Function name4 found
"function pwd --shadow-builtin" worked

7
tests/history.err Normal file
View File

@ -0,0 +1,7 @@
history: you cannot use any options with clear command
history: you cannot use any options with merge command
history: save command expected 0 args, got 1
history: you cannot use any options with save command
history: you cannot use any options with clear command
history: merge command expected 0 args, got 1
history: clear command expected 0 args, got 2

View File

@ -78,7 +78,7 @@ expect_prompt -re {\r\necho start1.*\r\necho start2} {
# ==========
# Verify implicit searching with a request for timestamps includes the timestamps.
send "history -t echo start\r"
expect_prompt -re {\r\n\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d echo start1; builtin history;.*\r\n\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d echo start2; builtin history} {
expect_prompt -re {\r\n# \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\r\necho start1; builtin history;.*\r\n# \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\r\necho start2; builtin history} {
puts "history function implicit search with timestamps succeeded"
} unmatched {
puts stderr "history function implicit search with timestamps failed"

13
tests/history.in Normal file
View File

@ -0,0 +1,13 @@
# Verify that specifying unexpected options or arguments results in an error.
# First with the history function.
history --clear --contains
history --merge -t
history --save xyz
# Now with the history builtin.
builtin history --save --prefix
builtin history --clear --with-time
builtin history --merge xyz
builtin history --clear abc def
# Now do a history command that should succeed.
builtin history --merge

0
tests/history.out Normal file
View File

View File

@ -0,0 +1 @@
2,34: value not completely converted

View File

@ -13,7 +13,7 @@ printf "%-20d%d\n" 5 10
printf "%*d\n" 10 100
printf "%%\"\\\n"
printf "%%\"\\\n"
printf "%s\b%s\n" x y
printf "abc\rdef\n"
printf "Msg1\fMsg2\n"
@ -34,4 +34,30 @@ printf "%5" 10 ^ /dev/null
# \376 is 0xFE
printf '\376' | xxd -p
true
# Verify that floating point conversions and output work correctly with
# different combinations of locales and floating point strings. See issue
# #3334. This starts by assuming an locale using english conventions.
printf '%e\n' "1.23" # should succeed, output should be 1.230000e+00
printf '%e\n' "2,34" # should fail
# Try to use one of several locales that use a comma as the decimal mark
# rather than the period used in english speaking locales. If we don't find
# one installed we simply don't run this test.
set -l locales (locale -a)
set -l acceptable_locales bg_BG de_DE es_ES fr_FR ru_RU
set -l numeric_locale
for locale in {$acceptable_locales}.{UTF-8,UTF8}
if string match -i -q $locale $locales
set numeric_locale $locale
break
end
end
if set -q numeric_locale[1]
set -x LC_NUMERIC $numeric_locale
printf '%e\n' "3,45" # should succeed, output should be 3,450000e+00
printf '%e\n' "4.56" # should succeed, output should be 4,560000e+00
else
echo '3,450000e+00'
echo '4,560000e+00'
end

View File

@ -14,3 +14,6 @@ I P Q R
Test escapes
a
fe
1.230000e+00
3,450000e+00
4,560000e+00