mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-19 06:31:13 -03:00
Merge branch 'master' into parsed
This commit is contained in:
13
common.cpp
13
common.cpp
@@ -1739,7 +1739,6 @@ bool string_prefixes_string(const wchar_t *proposed_prefix, const wcstring &valu
|
||||
return prefix_size <= value.size() && value.compare(0, prefix_size, proposed_prefix) == 0;
|
||||
}
|
||||
|
||||
|
||||
bool string_prefixes_string(const wcstring &proposed_prefix, const wcstring &value)
|
||||
{
|
||||
size_t prefix_size = proposed_prefix.size();
|
||||
@@ -1772,13 +1771,13 @@ static bool subsequence_in_string(const wcstring &seq, const wcstring &str)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Empty strings are considered to be subsequences of everything */
|
||||
if (seq.empty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
size_t str_idx, seq_idx;
|
||||
for (seq_idx = str_idx = 0; seq_idx < seq.size() && str_idx < str.size(); seq_idx++)
|
||||
{
|
||||
@@ -1795,16 +1794,16 @@ static bool subsequence_in_string(const wcstring &seq, const wcstring &str)
|
||||
str_idx = char_loc + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* We succeeded if we exhausted our sequence */
|
||||
assert(seq_idx <= seq.size());
|
||||
return seq_idx == seq.size();
|
||||
}
|
||||
|
||||
string_fuzzy_match_t::string_fuzzy_match_t(enum fuzzy_match_type_t t, size_t distance_first, size_t distance_second) :
|
||||
type(t),
|
||||
match_distance_first(distance_first),
|
||||
match_distance_second(distance_second)
|
||||
type(t),
|
||||
match_distance_first(distance_first),
|
||||
match_distance_second(distance_second)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
18
common.h
18
common.h
@@ -250,22 +250,22 @@ enum fuzzy_match_type_t
|
||||
{
|
||||
/* We match the string exactly: FOOBAR matches FOOBAR */
|
||||
fuzzy_match_exact = 0,
|
||||
|
||||
|
||||
/* We match a prefix of the string: FO matches FOOBAR */
|
||||
fuzzy_match_prefix,
|
||||
|
||||
|
||||
/* We match the string exactly, but in a case insensitive way: foobar matches FOOBAR */
|
||||
fuzzy_match_case_insensitive,
|
||||
|
||||
|
||||
/* We match a prefix of the string, in a case insensitive way: foo matches FOOBAR */
|
||||
fuzzy_match_prefix_case_insensitive,
|
||||
|
||||
|
||||
/* We match a substring of the string: OOBA matches FOOBAR */
|
||||
fuzzy_match_substring,
|
||||
|
||||
|
||||
/* A subsequence match with insertions only: FBR matches FOOBAR */
|
||||
fuzzy_match_subsequence_insertions_only,
|
||||
|
||||
|
||||
/* We don't match the string */
|
||||
fuzzy_match_none
|
||||
};
|
||||
@@ -302,14 +302,14 @@ static inline bool match_type_shares_prefix(fuzzy_match_type_t t)
|
||||
struct string_fuzzy_match_t
|
||||
{
|
||||
enum fuzzy_match_type_t type;
|
||||
|
||||
|
||||
/* Strength of the match. The value depends on the type. Lower is stronger. */
|
||||
size_t match_distance_first;
|
||||
size_t match_distance_second;
|
||||
|
||||
|
||||
/* Constructor */
|
||||
string_fuzzy_match_t(enum fuzzy_match_type_t t, size_t distance_first = 0, size_t distance_second = 0);
|
||||
|
||||
|
||||
/* Return -1, 0, 1 if this match is (respectively) better than, equal to, or worse than rhs */
|
||||
int compare(const string_fuzzy_match_t &rhs) const;
|
||||
};
|
||||
|
||||
24
complete.cpp
24
complete.cpp
@@ -375,7 +375,7 @@ class completer_t
|
||||
{
|
||||
return !!(flags & COMPLETION_REQUEST_FUZZY_MATCH);
|
||||
}
|
||||
|
||||
|
||||
fuzzy_match_type_t max_fuzzy_match_type() const
|
||||
{
|
||||
/* If we are doing fuzzy matching, request all types; if not request only prefix matching */
|
||||
@@ -439,11 +439,11 @@ public:
|
||||
expand_flags_t result = 0;
|
||||
if (this->type() == COMPLETE_AUTOSUGGEST)
|
||||
result |= EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_JOBS;
|
||||
|
||||
|
||||
/* Allow fuzzy matching */
|
||||
if (this->fuzzy())
|
||||
result |= EXPAND_FUZZY_MATCH;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1207,7 +1207,7 @@ void completer_t::complete_cmd(const wcstring &str_cmd, bool use_function, bool
|
||||
this->complete_cmd_desc(str_cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (use_function)
|
||||
{
|
||||
//function_get_names( &possible_comp, cmd[0] == L'_' );
|
||||
@@ -1658,22 +1658,22 @@ bool completer_t::complete_variable(const wcstring &str, size_t start_offset)
|
||||
const wchar_t *var = &whole_var[start_offset];
|
||||
size_t varlen = wcslen(var);
|
||||
bool res = false;
|
||||
|
||||
|
||||
const wcstring_list_t names = complete_get_variable_names();
|
||||
for (size_t i=0; i<names.size(); i++)
|
||||
{
|
||||
const wcstring & env_name = names.at(i);
|
||||
|
||||
|
||||
string_fuzzy_match_t match = string_fuzzy_match_string(var, env_name, this->max_fuzzy_match_type());
|
||||
if (match.type == fuzzy_match_none)
|
||||
{
|
||||
// No match
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
wcstring comp;
|
||||
int flags = 0;
|
||||
|
||||
|
||||
if (! match_type_requires_full_replacement(match.type))
|
||||
{
|
||||
// Take only the suffix
|
||||
@@ -1685,21 +1685,21 @@ bool completer_t::complete_variable(const wcstring &str, size_t start_offset)
|
||||
comp.append(env_name);
|
||||
flags = COMPLETE_REPLACES_TOKEN | COMPLETE_DONT_ESCAPE;
|
||||
}
|
||||
|
||||
|
||||
wcstring desc;
|
||||
if (this->wants_descriptions())
|
||||
{
|
||||
env_var_t value_unescaped = env_get_string(env_name);
|
||||
if (value_unescaped.missing())
|
||||
continue;
|
||||
|
||||
|
||||
wcstring value = expand_escape_variable(value_unescaped);
|
||||
if (this->type() != COMPLETE_AUTOSUGGEST)
|
||||
desc = format_string(COMPLETE_VAR_DESC_VAL, value.c_str());
|
||||
}
|
||||
|
||||
|
||||
append_completion(this->completions, comp.c_str(), desc.c_str(), flags, match);
|
||||
|
||||
|
||||
res = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class completion_t
|
||||
is case insensitive.
|
||||
*/
|
||||
int flags;
|
||||
|
||||
|
||||
/* Construction. Note: defining these so that they are not inlined reduces the executable size. */
|
||||
completion_t(const wcstring &comp, const wcstring &desc = L"", string_fuzzy_match_t match = string_fuzzy_match_t(fuzzy_match_exact), int flags_val = 0);
|
||||
completion_t(const completion_t &);
|
||||
|
||||
@@ -511,7 +511,7 @@ LIBS=$LIBS_COMMON
|
||||
# Check presense of various header files
|
||||
#
|
||||
|
||||
AC_CHECK_HEADERS([getopt.h termios.h sys/resource.h term.h ncurses/term.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h execinfo.h spawn.h])
|
||||
AC_CHECK_HEADERS([getopt.h termios.h sys/resource.h term.h ncurses/term.h ncurses.h curses.h stropts.h siginfo.h sys/select.h sys/ioctl.h execinfo.h spawn.h sys/sysctl.h])
|
||||
|
||||
if test x$local_gettext != xno; then
|
||||
AC_CHECK_HEADERS([libintl.h])
|
||||
|
||||
@@ -1377,69 +1377,6 @@ its initialization files to function properly. To solve this
|
||||
problem, either copy the initialization files to each fish users home
|
||||
directory, or install them in /etc.
|
||||
|
||||
\section i18n Translating fish to other languages
|
||||
|
||||
Fish uses the GNU gettext library to implement translation to multiple
|
||||
languages. If fish is not available in your language, please consider
|
||||
making a translation. Currently, only the shell itself can be
|
||||
translated, a future version of fish should also include translated
|
||||
manuals.
|
||||
|
||||
To make a translation of fish, you will first need the source code,
|
||||
available from the <a href='http://fishshell.com/'>fish
|
||||
homepage</a>. Download the latest version, and then extract it using a
|
||||
command like <code>tar -zxf fish-VERSION.tar.gz</code>.
|
||||
|
||||
Next, cd into the newly created fish directory using <code>cd
|
||||
fish-VERSION</code>.
|
||||
|
||||
You will now need to configure the source code using the command
|
||||
<code>./configure</code>. This step might take a while.
|
||||
|
||||
Before you continue, you will need to know the ISO 639 language code
|
||||
of the language you are translating to. These codes can be found <a
|
||||
href='http://www.w3.org/WAI/ER/IG/ert/iso639.htm'>here</a>. For
|
||||
example, the language code for Uighur is ug.
|
||||
|
||||
Now you have the source code and it is properly configured. Lets start
|
||||
translating. To do this, first create an empty translation table for
|
||||
the language you wish to translate to by writing <code>make
|
||||
po/[LANGUAGE CODE].po</code> in the fish terminal. For example, if you
|
||||
are translating to Uighur, you should write <code>make
|
||||
po/ug.po</code>. This should create the file po/ug.po, a template
|
||||
translation table containing all the strings that need to be
|
||||
translated.
|
||||
|
||||
Now you are all set up to translate fish to a new language. Open the
|
||||
newly created .po file in your editor of choice, and start
|
||||
translating. The .po file format is rather simple. It contains pairs
|
||||
of string in a format like:
|
||||
|
||||
<pre>
|
||||
msgid "%ls: No suitable job\n"
|
||||
msgstr ""
|
||||
</pre>
|
||||
|
||||
The first line is the English string to translate, the second line
|
||||
should contain your translation. For example, in Swedish the above
|
||||
might become:
|
||||
|
||||
<pre>
|
||||
msgid "%ls: No suitable job\n"
|
||||
msgstr "%ls: Inget passande jobb\n"
|
||||
</pre>
|
||||
|
||||
\%s, \%ls, \%d and other tokens beginning with a '\%' are
|
||||
placeholders. These will be replaced by a value by fish at
|
||||
runtime. You must always take care to use exactly the same
|
||||
placeholders in the same order in your translation. (Actually, there
|
||||
are ways to avoid this, but they are too complicated for this short
|
||||
introduction. See the full manual for the printf C function for more
|
||||
information.)
|
||||
|
||||
Once you have provided a translation for fish, please submit it via
|
||||
the instructions in <a href="#more-help">Further help and development</a>.
|
||||
|
||||
\section more-help Further help and development
|
||||
|
||||
If you have a question not answered by this documentation, there are
|
||||
|
||||
@@ -18,7 +18,9 @@ parameter expansion.
|
||||
#include <limits.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_SYS_SYSCTL_H
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
#include <termios.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
2
expand.h
2
expand.h
@@ -57,7 +57,7 @@ enum
|
||||
|
||||
/** Don't expand home directories */
|
||||
EXPAND_SKIP_HOME_DIRECTORIES = 1 << 9,
|
||||
|
||||
|
||||
/** Allow fuzzy matching */
|
||||
EXPAND_FUZZY_MATCH = 1 << 10
|
||||
};
|
||||
|
||||
@@ -989,18 +989,18 @@ static void test_complete(void)
|
||||
assert(completions.at(0).completion == L"oo1");
|
||||
assert(completions.at(1).completion == L"oo2");
|
||||
assert(completions.at(2).completion == L"oo3");
|
||||
|
||||
|
||||
completions.clear();
|
||||
complete(L"$1", completions, COMPLETION_REQUEST_DEFAULT);
|
||||
assert(completions.empty());
|
||||
|
||||
|
||||
completions.clear();
|
||||
complete(L"$1", completions, COMPLETION_REQUEST_DEFAULT | COMPLETION_REQUEST_FUZZY_MATCH);
|
||||
assert(completions.size() == 2);
|
||||
assert(completions.at(0).completion == L"$Foo1");
|
||||
assert(completions.at(1).completion == L"$Bar1");
|
||||
|
||||
|
||||
|
||||
complete_set_variable_names(NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ static const wchar_t * const name_arr[] =
|
||||
L"history-token-search-forward",
|
||||
L"self-insert",
|
||||
L"transpose-chars",
|
||||
L"transpose-words",
|
||||
L"null",
|
||||
L"eof",
|
||||
L"vi-arg-digit",
|
||||
@@ -199,6 +200,7 @@ static const wchar_t code_arr[] =
|
||||
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
||||
R_SELF_INSERT,
|
||||
R_TRANSPOSE_CHARS,
|
||||
R_TRANSPOSE_WORDS,
|
||||
R_NULL,
|
||||
R_EOF,
|
||||
R_VI_ARG_DIGIT,
|
||||
|
||||
1
input.h
1
input.h
@@ -43,6 +43,7 @@ enum
|
||||
R_HISTORY_TOKEN_SEARCH_FORWARD,
|
||||
R_SELF_INSERT,
|
||||
R_TRANSPOSE_CHARS,
|
||||
R_TRANSPOSE_WORDS,
|
||||
R_VI_ARG_DIGIT,
|
||||
R_VI_DELETE_TO,
|
||||
R_EXECUTE,
|
||||
|
||||
10
osx/config.h
10
osx/config.h
@@ -109,14 +109,14 @@
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/termios.h> header file. */
|
||||
#define HAVE_SYS_TERMIOS_H 1
|
||||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#define HAVE_SYS_SYSCTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <termio.h> header file. */
|
||||
/* #undef HAVE_TERMIO_H */
|
||||
/* Define to 1 if you have the <termios.h> header file. */
|
||||
#define HAVE_TERMIOS_H 1
|
||||
|
||||
/* Define to 1 if you have the <term.h> header file. */
|
||||
#define HAVE_TERM_H 1
|
||||
@@ -204,7 +204,7 @@
|
||||
/* #undef TPUTS_KLUDGE */
|
||||
|
||||
/* Perform string translations with gettext */
|
||||
#define USE_GETTEXT 1
|
||||
/* #undef USE_GETTEXT */
|
||||
|
||||
/* Macro to enable additional prototypes under BSD */
|
||||
/* #undef _NETBSD_SOURCE */
|
||||
|
||||
@@ -2042,7 +2042,7 @@ int parser_t::parse_job(process_t *p,
|
||||
free(cpy);
|
||||
|
||||
}
|
||||
else if (cmd[0]==L'$')
|
||||
else if (cmd[0]==L'$' || cmd[0] == VARIABLE_EXPAND || cmd[0] == VARIABLE_EXPAND_SINGLE)
|
||||
{
|
||||
|
||||
const env_var_t val_wstr = env_get_string(cmd+1);
|
||||
|
||||
85
reader.cpp
85
reader.cpp
@@ -1139,12 +1139,12 @@ static void run_pager(const wcstring &prefix, int is_quoted, const std::vector<c
|
||||
prefix_esc.c_str());
|
||||
|
||||
escaped_separator = escape(COMPLETE_SEP_STR, 1);
|
||||
|
||||
|
||||
for (size_t i=0; i< comp.size(); i++)
|
||||
{
|
||||
long base_len=-1;
|
||||
const completion_t &el = comp.at(i);
|
||||
|
||||
|
||||
wcstring completion_text;
|
||||
wcstring description_text;
|
||||
|
||||
@@ -1498,7 +1498,7 @@ static void prioritize_completions(std::vector<completion_t> &comp)
|
||||
if (el.match.type < best_type)
|
||||
best_type = el.match.type;
|
||||
}
|
||||
|
||||
|
||||
/* Throw out completions whose match types are not the best. */
|
||||
i = comp.size();
|
||||
while (i--)
|
||||
@@ -1508,7 +1508,7 @@ static void prioritize_completions(std::vector<completion_t> &comp)
|
||||
comp.erase(comp.begin() + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Sort the remainder */
|
||||
sort(comp.begin(), comp.end(), compare_completions_by_match_type);
|
||||
}
|
||||
@@ -1536,7 +1536,7 @@ static const completion_t *cycle_competions(const std::vector<completion_t> &com
|
||||
const completion_t &c = comp.at(idx);
|
||||
|
||||
/* Try this completion */
|
||||
if (! (c.flags & COMPLETE_REPLACES_TOKEN) || reader_can_replace(command_line, c.flags))
|
||||
if (!(c.flags & COMPLETE_REPLACES_TOKEN) || reader_can_replace(command_line, c.flags))
|
||||
{
|
||||
/* Success */
|
||||
result = &c;
|
||||
@@ -1605,7 +1605,7 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
the token doesn't contain evil operators
|
||||
like {}
|
||||
*/
|
||||
if (! (c.flags & COMPLETE_REPLACES_TOKEN) || reader_can_replace(tok, c.flags))
|
||||
if (!(c.flags & COMPLETE_REPLACES_TOKEN) || reader_can_replace(tok, c.flags))
|
||||
{
|
||||
completion_insert(c.completion.c_str(), c.flags);
|
||||
}
|
||||
@@ -1618,7 +1618,7 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
|
||||
if (!done)
|
||||
{
|
||||
|
||||
|
||||
/* Determine the type of the best match(es) */
|
||||
fuzzy_match_type_t best_match_type = fuzzy_match_none;
|
||||
for (size_t i=0; i < comp.size(); i++)
|
||||
@@ -1629,19 +1629,19 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
best_match_type = el.match.type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Determine whether we are going to replace the token or not. If any commands of the best type do not require replacement, then ignore all those that want to use replacement */
|
||||
bool will_replace_token = true;
|
||||
for (size_t i=0; i< comp.size(); i++)
|
||||
{
|
||||
const completion_t &el = comp.at(i);
|
||||
if (el.match.type == best_match_type && ! (el.flags & COMPLETE_REPLACES_TOKEN))
|
||||
if (el.match.type == best_match_type && !(el.flags & COMPLETE_REPLACES_TOKEN))
|
||||
{
|
||||
will_replace_token = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Decide which completions survived. There may be a lot of them; it would be nice if we could figure out how to avoid copying them here */
|
||||
std::vector<completion_t> surviving_completions;
|
||||
for (size_t i=0; i < comp.size(); i++)
|
||||
@@ -1650,21 +1650,21 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
/* Only use completions with the best match type */
|
||||
if (el.match.type != best_match_type)
|
||||
continue;
|
||||
|
||||
|
||||
/* Only use completions that match replace_token */
|
||||
bool completion_replace_token = !! (el.flags & COMPLETE_REPLACES_TOKEN);
|
||||
bool completion_replace_token = !!(el.flags & COMPLETE_REPLACES_TOKEN);
|
||||
if (completion_replace_token != will_replace_token)
|
||||
continue;
|
||||
|
||||
|
||||
/* Don't use completions that want to replace, if we cannot replace them */
|
||||
if (completion_replace_token && ! reader_can_replace(tok, el.flags))
|
||||
continue;
|
||||
|
||||
|
||||
/* This completion survived */
|
||||
surviving_completions.push_back(el);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Try to find a common prefix to insert among the surviving completions */
|
||||
wcstring common_prefix;
|
||||
complete_flags_t flags = 0;
|
||||
@@ -1682,7 +1682,8 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
{
|
||||
/* Determine the shared prefix length. */
|
||||
size_t idx, max = mini(common_prefix.size(), el.completion.size());
|
||||
for (idx=0; idx < max; idx++) {
|
||||
for (idx=0; idx < max; idx++)
|
||||
{
|
||||
wchar_t ac = common_prefix.at(idx), bc = el.completion.at(idx);
|
||||
bool matches = (ac == bc);
|
||||
/* If we are replacing the token, allow case to vary */
|
||||
@@ -1694,17 +1695,17 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
if (! matches)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* idx is now the length of the new common prefix */
|
||||
common_prefix.resize(idx);
|
||||
prefix_is_partial_completion = true;
|
||||
|
||||
|
||||
/* Early out if we decide there's no common prefix */
|
||||
if (idx == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! common_prefix.empty())
|
||||
{
|
||||
/* We got something. If more than one completion contributed, then it means we have a prefix; don't insert a space after it */
|
||||
@@ -1722,7 +1723,7 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
|
||||
assert(data->buff_pos >= prefix_start);
|
||||
len = data->buff_pos - prefix_start;
|
||||
|
||||
|
||||
if (match_type_requires_full_replacement(best_match_type))
|
||||
{
|
||||
// No prefix
|
||||
@@ -1751,7 +1752,7 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
reader_repaint_without_autosuggestion();
|
||||
|
||||
write_loop(1, "\n", 1);
|
||||
|
||||
|
||||
run_pager(prefix, is_quoted, surviving_completions);
|
||||
}
|
||||
s_reset(&data->screen, screen_reset_abandon_line);
|
||||
@@ -3553,6 +3554,46 @@ const wchar_t *reader_readline(void)
|
||||
break;
|
||||
}
|
||||
|
||||
case R_TRANSPOSE_WORDS:
|
||||
{
|
||||
size_t len = data->command_length();
|
||||
const wchar_t *buff = data->command_line.c_str();
|
||||
const wchar_t *tok_begin, *tok_end, *prev_begin, *prev_end;
|
||||
|
||||
/* If we are not in a token, look for one ahead */
|
||||
while (data->buff_pos != len && !iswalnum(buff[data->buff_pos]))
|
||||
data->buff_pos++;
|
||||
|
||||
parse_util_token_extent(buff, data->buff_pos, &tok_begin, &tok_end, &prev_begin, &prev_end);
|
||||
|
||||
/* In case we didn't find a token at or after the cursor... */
|
||||
if (tok_begin == &buff[len])
|
||||
{
|
||||
/* ...retry beginning from the previous token */
|
||||
size_t pos = prev_end - &buff[0];
|
||||
parse_util_token_extent(buff, pos, &tok_begin, &tok_end, &prev_begin, &prev_end);
|
||||
}
|
||||
|
||||
/* Make sure we have two tokens */
|
||||
if (prev_begin < prev_end && tok_begin < tok_end && tok_begin > prev_begin)
|
||||
{
|
||||
const wcstring prev(prev_begin, prev_end - prev_begin);
|
||||
const wcstring sep(prev_end, tok_begin - prev_end);
|
||||
const wcstring tok(tok_begin, tok_end - tok_begin);
|
||||
const wcstring trail(tok_end, &buff[len] - tok_end);
|
||||
|
||||
/* Compose new command line with swapped tokens */
|
||||
wcstring new_buff(buff, prev_begin - buff);
|
||||
new_buff.append(tok);
|
||||
new_buff.append(sep);
|
||||
new_buff.append(prev);
|
||||
new_buff.append(trail);
|
||||
/* Put cursor right after the second token */
|
||||
set_command_line_and_position(new_buff, tok_end - buff);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Other, if a normal character, we add it to the command */
|
||||
default:
|
||||
{
|
||||
|
||||
@@ -289,7 +289,7 @@ static prompt_layout_t calc_prompt_layout(const wchar_t *prompt)
|
||||
if (prompt[j+1] == L'k')
|
||||
{
|
||||
const env_var_t term_name = env_get_string(L"TERM");
|
||||
if (!term_name.missing() && wcsstr(term_name.c_str(), L"screen") == term_name)
|
||||
if (!term_name.missing() && string_prefixes_string(L"screen", term_name))
|
||||
{
|
||||
const wchar_t *end;
|
||||
j+=2;
|
||||
|
||||
34
share/completions/apt-mark.fish
Normal file
34
share/completions/apt-mark.fish
Normal file
@@ -0,0 +1,34 @@
|
||||
#completion for apt-mark
|
||||
|
||||
function __fish_apt_no_subcommand --description 'Test if apt has yet to be given the subcommand'
|
||||
for i in (commandline -opc)
|
||||
if contains -- $i auto manual hold unhold showauto showmanual showhold
|
||||
return 1
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function __fish_apt_use_package --description 'Test if apt command should have packages as potential completion'
|
||||
for i in (commandline -opc)
|
||||
if contains -- $i contains auto manual hold unhold
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
complete -c apt-mark -n '__fish_apt_use_package' -a '(__fish_print_packages)' --description 'Package'
|
||||
|
||||
complete -c apt-mark -s h -l help --description 'Display help and exit'
|
||||
complete -f -n '__fish_apt_no_subcommand' -c apt-mark -a 'auto' --description 'Mark a package as automatically installed'
|
||||
complete -f -n '__fish_apt_no_subcommand' -c apt-mark -a 'manual' --description 'Mark a package as manually installed'
|
||||
complete -f -n '__fish_apt_no_subcommand' -c apt-mark -a 'hold' --description 'Hold a package, prevent automatic installation or removal'
|
||||
complete -f -n '__fish_apt_no_subcommand' -c apt-mark -a 'unhold' --description 'Cancel a hold on a package'
|
||||
complete -f -n '__fish_apt_no_subcommand' -c apt-mark -a 'showauto' --description 'Show automatically installed packages'
|
||||
complete -f -n '__fish_apt_no_subcommand' -c apt-mark -a 'showmanual' --description 'Show manually installed packages'
|
||||
complete -f -n '__fish_apt_no_subcommand' -c apt-mark -a 'showhold' --description 'Show held packages'
|
||||
complete -c apt-mark -s v -l version --description 'Display version and exit'
|
||||
complete -r -c apt-mark -s c -l config-file --description 'Specify a config file'
|
||||
complete -r -c apt-mark -s o -l option --description 'Set a config option'
|
||||
complete -r -c apt-mark -s f -l file --description 'Write package statistics to a file'
|
||||
6
share/completions/head.fish
Normal file
6
share/completions/head.fish
Normal file
@@ -0,0 +1,6 @@
|
||||
complete -c head -s c -l bytes -d 'Print the first N bytes; Leading '-', truncate the last N bytes' -r
|
||||
complete -c head -s n -l lines -d 'Print the first N lines; Leading '-', truncate the last N lines' -r
|
||||
complete -c head -s q -l quiet -l silent -d 'Never print file names'
|
||||
complete -c head -s v -l verbose -d 'Always print file names'
|
||||
complete -f -c head -l version -d 'Display version'
|
||||
complete -f -c head -l help -d 'Display help'
|
||||
47
share/completions/lunchy.fish
Normal file
47
share/completions/lunchy.fish
Normal file
@@ -0,0 +1,47 @@
|
||||
function __fish_lunchy_needs_command
|
||||
set cmd (commandline -opc)
|
||||
|
||||
if test (count $cmd) -eq 1
|
||||
return 0
|
||||
end
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fish_lunchy_using_command
|
||||
set cmd (commandline -opc)
|
||||
set cmd_count (count $cmd)
|
||||
|
||||
if test $cmd_count -lt 2
|
||||
return 1
|
||||
end
|
||||
|
||||
for arg in $argv
|
||||
if test $arg = $cmd[2]
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
complete -f -c lunchy -s v -l verbose -d 'Show command executions'
|
||||
|
||||
# Commands
|
||||
complete -f -c lunchy -n '__fish_lunchy_needs_command' -a install -d 'Installs [file] to ~/Library/LaunchAgents or /Library/LaunchAgents'
|
||||
complete -f -c lunchy -n '__fish_lunchy_needs_command' -a 'ls list' -d 'Show the list of installed agents'
|
||||
complete -f -c lunchy -n '__fish_lunchy_needs_command' -a start -d 'Start the first matching agent'
|
||||
complete -f -c lunchy -n '__fish_lunchy_needs_command' -a stop -d 'Stop the first matching agent'
|
||||
complete -f -c lunchy -n '__fish_lunchy_needs_command' -a restart -d 'Stop and start the first matching agent'
|
||||
complete -f -c lunchy -n '__fish_lunchy_needs_command' -a status -d 'Show the PID and label for all agents'
|
||||
complete -f -c lunchy -n '__fish_lunchy_needs_command' -a edit -d 'Opens the launchctl daemon file in the default editor'
|
||||
|
||||
# Commands with service completion
|
||||
complete -f -c lunchy -n '__fish_lunchy_using_command ls list start stop restart status edit' -a '(lunchy ls)' -d 'Service'
|
||||
|
||||
# Command: start
|
||||
complete -f -c lunchy -n '__fish_lunchy_using_command start' -s w -l write -d 'Persist command'
|
||||
complete -f -c lunchy -n '__fish_lunchy_using_command start' -s F -l force -d 'Force start (disabled) agents'
|
||||
|
||||
# Command: stop
|
||||
complete -f -c lunchy -n '__fish_lunchy_using_command stop' -s w -l write -d 'Persist command'
|
||||
52
share/completions/netctl.fish
Normal file
52
share/completions/netctl.fish
Normal file
@@ -0,0 +1,52 @@
|
||||
function __fish_netctl_needs_command
|
||||
set cmd (commandline -opc)
|
||||
if [ (count $cmd) -eq 1 -a $cmd[1] = 'netctl' ]
|
||||
return 0
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fish_netctl_using_command
|
||||
set cmd (commandline -opc)
|
||||
if [ (count $cmd) -gt 1 ]
|
||||
if [ $argv[1] = $cmd[2] ]
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
function __fish_netctl_get_profiles
|
||||
command netctl list | sed -e 's/^[ \t*]*//'
|
||||
end
|
||||
|
||||
complete -f -c netctl -l help -d 'Display help'
|
||||
complete -f -c netctl -l version -d 'Display version'
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a list -d 'List available profiles'
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a store -d 'Save which profiles are active'
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a restore -d 'Load saved profiles'
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a stop-all -d 'Stops all profiles'
|
||||
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a start -d 'Start a profile'
|
||||
complete -f -c netctl -n '__fish_netctl_using_command start' -a '(__fish_netctl_get_profiles)' -d 'Profile'
|
||||
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a stop -d 'Stop a profile'
|
||||
complete -f -c netctl -n '__fish_netctl_using_command stop' -a '(__fish_netctl_get_profiles)' -d 'Profile'
|
||||
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a restart -d 'Restart a profile'
|
||||
complete -f -c netctl -n '__fish_netctl_using_command restart' -a '(__fish_netctl_get_profiles)' -d 'Profile'
|
||||
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a switch-to -d 'Switch to a profile'
|
||||
complete -f -c netctl -n '__fish_netctl_using_command switch-to' -a '(__fish_netctl_get_profiles)' -d 'Profile'
|
||||
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a status -d 'Show runtime status of a profile'
|
||||
complete -f -c netctl -n '__fish_netctl_using_command status' -a '(__fish_netctl_get_profiles)' -d 'Profile'
|
||||
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a enable -d 'Enable the systemd unit for a profile'
|
||||
complete -f -c netctl -n '__fish_netctl_using_command enable' -a '(__fish_netctl_get_profiles)' -d 'Profile'
|
||||
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a disable -d 'Disable the systemd unit for a profile'
|
||||
complete -f -c netctl -n '__fish_netctl_using_command disable' -a '(__fish_netctl_get_profiles)' -d 'Profile'
|
||||
|
||||
complete -f -c netctl -n '__fish_netctl_needs_command' -a reenable -d 'Reenable the systemd unit for a profile'
|
||||
complete -f -c netctl -n '__fish_netctl_using_command reenable' -a '(__fish_netctl_get_profiles)' -d 'Profile'
|
||||
@@ -104,3 +104,15 @@ complete -c rsync -s 6 -l ipv6 --description "Prefer IPv6"
|
||||
complete -c rsync -l version --description "Display version and exit"
|
||||
complete -c rsync -l help --description "Display help and exit"
|
||||
|
||||
#
|
||||
# Remote path
|
||||
#
|
||||
complete -c rsync -d "Remote path" -n "commandline -ct|sgrep -q :" -a "
|
||||
(
|
||||
#Prepend any user@host:/path information supplied before the remote completion
|
||||
commandline -ct|sgrep -Eo '.*:+(.*/)?'
|
||||
)(
|
||||
#Get the list of remote files from the specified rsync server
|
||||
rsync --list-only (commandline -ct|sgrep -Eo '.*:+(.*/)?') ^/dev/null | awk '{if (\$1 ~ \"^d\" ) {print \$NF \"/\";} else {print \$NF;} };'
|
||||
)
|
||||
"
|
||||
|
||||
@@ -17,7 +17,7 @@ complete -c scp -d Hostname -a "
|
||||
|
||||
(
|
||||
#Prepend any username specified in the completion to the hostname
|
||||
echo (commandline -ct)|sed -ne 's/\(.*@\).*/\1/p'
|
||||
commandline -ct |sed -ne 's/\(.*@\).*/\1/p'
|
||||
)(
|
||||
cat ~/.ssh/known_hosts{,2} ^/dev/null|cut -d ' ' -f 1| cut -d , -f 1
|
||||
):
|
||||
@@ -29,14 +29,14 @@ complete -c scp -d Hostname -a "
|
||||
#
|
||||
# Remote path
|
||||
#
|
||||
complete -c scp -d "Remote Path" -n "echo (commandline -ct)|sgrep -o '.*:';and true" -a "
|
||||
complete -c scp -d "Remote Path" -n "commandline -ct|sgrep -o '.*:'" -a "
|
||||
|
||||
(
|
||||
#Prepend any user@host information supplied before the remote completion
|
||||
echo (commandline -ct)|sgrep -o '.*:'
|
||||
commandline -ct|sgrep -o '.*:'
|
||||
)(
|
||||
#Get the list of remote files from the specified ssh server
|
||||
ssh -o \"BatchMode yes\" (echo (commandline -ct)|sed -ne 's/\(.*\):.*/\1/p') ls\ -dp\ (echo (commandline -ct)|sed -ne 's/.*://p')\*
|
||||
ssh -o \"BatchMode yes\" (commandline -ct|sed -ne 's/\(.*\):.*/\1/p') ls\ -dp\ (commandline -ct|sed -ne 's/.*://p')\* 2> /dev/null
|
||||
)
|
||||
|
||||
"
|
||||
|
||||
@@ -124,7 +124,7 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
||||
set -l svn_upstream (git log --first-parent -1 --grep="^git-svn-id: \($svn_url_pattern\)" ^/dev/null)
|
||||
if test (count $svn_upstream) -ne 0
|
||||
echo $svn_upstream[-1] | read -l _ svn_upstream _
|
||||
set svn_upstream (/bin/sh -c 'echo "${1%@*}"' -- $svn_upstream)
|
||||
set svn_upstream (/bin/sh -c 'echo "${1%@*}"' -- $svn_upstream)
|
||||
set -l cur_prefix
|
||||
for i in (seq (count $svn_remote))
|
||||
set -l remote $svn_remote[$i]
|
||||
@@ -145,7 +145,7 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
||||
set upstream git-svn
|
||||
end
|
||||
else
|
||||
set upstream (/bin/sh -c 'val=${1#/branches}; echo "${val#/}"' -- $svn_upstream)
|
||||
set upstream (/bin/sh -c 'val=${1#/branches}; echo "${val#/}"' -- $svn_upstream)
|
||||
set -l fetch_val (git config "$cur_prefix".fetch)
|
||||
if test -n "$fetch_val"
|
||||
set -l IFS :
|
||||
@@ -153,8 +153,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
||||
set upstream (/bin/sh -c 'echo "${1%/$2}"' -- $pattern $trunk)/$upstream
|
||||
end
|
||||
end
|
||||
else if test $upstream = svn+git
|
||||
set upstream '@{upstream}'
|
||||
else if test $upstream = svn+git
|
||||
set upstream '@{upstream}'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -193,54 +193,54 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi
|
||||
switch "$count"
|
||||
case '' # no upstream
|
||||
case "0 0" # equal to upstream
|
||||
echo " $___fish_git_prompt_char_upstream_equal"
|
||||
echo " $___fish_git_prompt_char_upstream_equal"
|
||||
case "0 *" # ahead of upstream
|
||||
echo " $___fish_git_prompt_char_upstream_ahead$ahead"
|
||||
echo " $___fish_git_prompt_char_upstream_ahead$ahead"
|
||||
case "* 0" # behind upstream
|
||||
echo " $___fish_git_prompt_char_upstream_behind$behind"
|
||||
echo " $___fish_git_prompt_char_upstream_behind$behind"
|
||||
case '*' # diverged from upstream
|
||||
echo " $__fish_git_prompt_char_upstream_diverged$ahead-$behind"
|
||||
echo " $__fish_git_prompt_char_upstream_diverged$ahead-$behind"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function __fish_git_prompt --description "Prompt function for Git"
|
||||
set -l git_dir (__fish_git_prompt_git_dir)
|
||||
set -l git_dir (__fish_git_prompt_git_dir)
|
||||
test -n "$git_dir"; or return
|
||||
|
||||
set -l r (__fish_git_prompt_current_operation $git_dir)
|
||||
set -l b (__fish_git_prompt_current_branch)
|
||||
set -l w #dirty working directory
|
||||
set -l i #staged changes
|
||||
set -l s #stashes
|
||||
set -l u #untracked
|
||||
set -l c (__fish_git_prompt_current_branch_bare)
|
||||
set -l p #upstream
|
||||
set -l r (__fish_git_prompt_current_operation $git_dir)
|
||||
set -l b (__fish_git_prompt_current_branch)
|
||||
set -l w #dirty working directory
|
||||
set -l i #staged changes
|
||||
set -l s #stashes
|
||||
set -l u #untracked
|
||||
set -l c (__fish_git_prompt_current_branch_bare)
|
||||
set -l p #upstream
|
||||
|
||||
__fish_git_prompt_validate_chars
|
||||
|
||||
if test "true" = (git rev-parse --is-inside-work-tree ^/dev/null)
|
||||
if test -n "$__fish_git_prompt_showdirtystate"
|
||||
set -l config (git config --bool bash.showDirtyState)
|
||||
if test "$config" != "false"
|
||||
set w (__fish_git_prompt_dirty)
|
||||
set i (__fish_git_prompt_staged)
|
||||
end
|
||||
end
|
||||
if test "true" = (git rev-parse --is-inside-work-tree ^/dev/null)
|
||||
if test -n "$__fish_git_prompt_showdirtystate"
|
||||
set -l config (git config --bool bash.showDirtyState)
|
||||
if test "$config" != "false"
|
||||
set w (__fish_git_prompt_dirty)
|
||||
set i (__fish_git_prompt_staged)
|
||||
end
|
||||
end
|
||||
|
||||
if test -n "$__fish_git_prompt_showstashstate"
|
||||
git rev-parse --verify refs/stash >/dev/null ^&1; and set s $___fish_git_prompt_char_stashstate
|
||||
end
|
||||
if test -n "$__fish_git_prompt_showstashstate"
|
||||
git rev-parse --verify refs/stash >/dev/null ^&1; and set s $___fish_git_prompt_char_stashstate
|
||||
end
|
||||
|
||||
if test -n "$__fish_git_prompt_showuntrackedfiles"
|
||||
set -l files (git ls-files --others --exclude-standard)
|
||||
if test -n "$files"
|
||||
set u $___fish_git_prompt_char_untrackedfiles
|
||||
end
|
||||
end
|
||||
if test -n "$__fish_git_prompt_showuntrackedfiles"
|
||||
set -l files (git ls-files --others --exclude-standard)
|
||||
if test -n "$files"
|
||||
set u $___fish_git_prompt_char_untrackedfiles
|
||||
end
|
||||
end
|
||||
|
||||
if test -n "$__fish_git_prompt_showupstream"
|
||||
set p (__fish_git_prompt_show_upstream)
|
||||
if test -n "$__fish_git_prompt_showupstream"
|
||||
set p (__fish_git_prompt_show_upstream)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -272,15 +272,15 @@ function __fish_git_prompt --description "Prompt function for Git"
|
||||
set p "$___fish_git_prompt_color_upstream$p$___fish_git_prompt_color_upstream_done"
|
||||
end
|
||||
|
||||
# Formatting
|
||||
set -l f "$w$i$s$u"
|
||||
if test -n "$f"
|
||||
set f " $f"
|
||||
end
|
||||
set -l format $argv[1]
|
||||
if test -z "$format"
|
||||
set format " (%s)"
|
||||
end
|
||||
# Formatting
|
||||
set -l f "$w$i$s$u"
|
||||
if test -n "$f"
|
||||
set f " $f"
|
||||
end
|
||||
set -l format $argv[1]
|
||||
if test -z "$format"
|
||||
set format " (%s)"
|
||||
end
|
||||
|
||||
printf "%s$format%s" "$___fish_git_prompt_color_prefix" "$___fish_git_prompt_color_prefix_done$c$b$f$r$p$___fish_git_prompt_color_suffix" "$___git_ps_color_suffix_done"
|
||||
end
|
||||
@@ -288,102 +288,103 @@ end
|
||||
### helper functions
|
||||
|
||||
function __fish_git_prompt_staged --description "__fish_git_prompt helper, tells whether or not the current branch has staged files"
|
||||
set -l staged
|
||||
set -l staged
|
||||
|
||||
if git rev-parse --quiet --verify HEAD >/dev/null
|
||||
git diff-index --cached --quiet HEAD --; or set staged $___fish_git_prompt_char_stagedstate
|
||||
else
|
||||
set staged $___fish_git_prompt_char_invalidstate
|
||||
end
|
||||
if git rev-parse --quiet --verify HEAD >/dev/null
|
||||
git diff-index --cached --quiet HEAD --; or set staged $___fish_git_prompt_char_stagedstate
|
||||
else
|
||||
set staged $___fish_git_prompt_char_invalidstate
|
||||
end
|
||||
echo $staged
|
||||
end
|
||||
|
||||
function __fish_git_prompt_dirty --description "__fish_git_prompt helper, tells whether or not the current branch has tracked, modified files"
|
||||
set -l dirty
|
||||
set -l dirty
|
||||
|
||||
set -l os
|
||||
git diff --no-ext-diff --quiet --exit-code
|
||||
set os $status
|
||||
if test $os -ne 0
|
||||
set dirty $___fish_git_prompt_char_dirtystate
|
||||
end
|
||||
echo $dirty
|
||||
set -l os
|
||||
git diff --no-ext-diff --quiet --exit-code
|
||||
set os $status
|
||||
if test $os -ne 0
|
||||
set dirty $___fish_git_prompt_char_dirtystate
|
||||
end
|
||||
echo $dirty
|
||||
end
|
||||
|
||||
function __fish_git_prompt_current_branch_bare --description "__fish_git_prompt helper, tells wheter or not the current branch is bare"
|
||||
set -l bare
|
||||
set -l bare
|
||||
|
||||
if test "true" = (git rev-parse --is-inside-git-dir ^/dev/null)
|
||||
if test "true" = (git rev-parse --is-bare-repository ^/dev/null)
|
||||
set bare "BARE:"
|
||||
end
|
||||
end
|
||||
echo $bare
|
||||
if test "true" = (git rev-parse --is-inside-git-dir ^/dev/null)
|
||||
if test "true" = (git rev-parse --is-bare-repository ^/dev/null)
|
||||
set bare "BARE:"
|
||||
end
|
||||
end
|
||||
echo $bare
|
||||
end
|
||||
|
||||
function __fish_git_prompt_current_branch --description "__fish_git_prompt helper, returns the current Git branch"
|
||||
set -l branch
|
||||
set -l branch
|
||||
|
||||
set -l os
|
||||
set branch (git symbolic-ref HEAD ^/dev/null; set os $status)
|
||||
if test $os -ne 0
|
||||
set branch (switch "$__fish_git_prompt_describe_style"
|
||||
case contains
|
||||
git describe --contains HEAD
|
||||
case branch
|
||||
git describe --contains --all HEAD
|
||||
case describe
|
||||
git describe HEAD
|
||||
case default '*'
|
||||
git describe --tags --exact-match HEAD
|
||||
end ^/dev/null; set os $status)
|
||||
if test $os -ne 0
|
||||
set branch (cut -c1-7 $git_dir/HEAD ^/dev/null; set os $status)
|
||||
if test $os -ne 0
|
||||
set branch unknown
|
||||
end
|
||||
end
|
||||
set branch "($branch)"
|
||||
end
|
||||
set -l os
|
||||
set branch (git symbolic-ref HEAD ^/dev/null; set os $status)
|
||||
if test $os -ne 0
|
||||
set branch (switch "$__fish_git_prompt_describe_style"
|
||||
case contains
|
||||
git describe --contains HEAD
|
||||
case branch
|
||||
git describe --contains --all HEAD
|
||||
case describe
|
||||
git describe HEAD
|
||||
case default '*'
|
||||
git describe --tags --exact-match HEAD
|
||||
end ^/dev/null; set os $status)
|
||||
if test $os -ne 0
|
||||
set branch (cut -c1-7 $git_dir/HEAD ^/dev/null; set os $status)
|
||||
if test $os -ne 0
|
||||
set branch unknown
|
||||
end
|
||||
end
|
||||
set branch "($branch)"
|
||||
end
|
||||
|
||||
# I honestly don't know when this is relevant
|
||||
if test "true" = (git rev-parse --is-inside-git-dir ^/dev/null)
|
||||
if test "false" = (git rev-parse --is-bare-repository ^/dev/null)
|
||||
set branch "GIT_DIR!"
|
||||
end
|
||||
end
|
||||
echo $branch
|
||||
# Let user know they're inside the git dir of a non-bare repo
|
||||
if test "true" = (git rev-parse --is-inside-git-dir ^/dev/null)
|
||||
if test "false" = (git rev-parse --is-bare-repository ^/dev/null)
|
||||
set branch "GIT_DIR!"
|
||||
end
|
||||
end
|
||||
echo $branch
|
||||
end
|
||||
|
||||
function __fish_git_prompt_current_operation --description "__fish_git_prompt helper, returns the current Git operation being performed"
|
||||
set -l operation
|
||||
set -l operation
|
||||
|
||||
set -l git_dir $argv[1]
|
||||
if test -f $git_dir/rebase-merge/interactive
|
||||
set operation "|REBASE-i"
|
||||
else if test -d $git_dir/rebase-merge
|
||||
set operation "|REBASE-m"
|
||||
else
|
||||
if test -d $git_dir/rebase-apply
|
||||
if test -f $git_dir/rebase-apply/rebasing
|
||||
set operation "|REBASE"
|
||||
else if test -f $git_dir/rebase-apply/applying
|
||||
set operation "|AM"
|
||||
else
|
||||
set operation "|AM/REBASE"
|
||||
end
|
||||
else if test -f $git_dir/MERGE_HEAD
|
||||
set operation "|MERGING"
|
||||
else if test -f $git_dir/CHERRY_PICK_HEAD
|
||||
set operation "|CHERRY-PICKING"
|
||||
else if test -f $git_dir/BISECT_LOG
|
||||
set operation "|BISECTING"
|
||||
end
|
||||
end
|
||||
echo $operation
|
||||
set -l git_dir $argv[1]
|
||||
if test -f $git_dir/rebase-merge/interactive
|
||||
set operation "|REBASE-i"
|
||||
else if test -d $git_dir/rebase-merge
|
||||
set operation "|REBASE-m"
|
||||
else
|
||||
if test -d $git_dir/rebase-apply
|
||||
if test -f $git_dir/rebase-apply/rebasing
|
||||
set operation "|REBASE"
|
||||
else if test -f $git_dir/rebase-apply/applying
|
||||
set operation "|AM"
|
||||
else
|
||||
set operation "|AM/REBASE"
|
||||
end
|
||||
else if test -f $git_dir/MERGE_HEAD
|
||||
set operation "|MERGING"
|
||||
else if test -f $git_dir/CHERRY_PICK_HEAD
|
||||
set operation "|CHERRY-PICKING"
|
||||
else if test -f $git_dir/BISECT_LOG
|
||||
set operation "|BISECTING"
|
||||
end
|
||||
end
|
||||
echo $operation
|
||||
end
|
||||
|
||||
function __fish_git_prompt_git_dir --description "__fish_git_prompt helper, returns .git dir if any"
|
||||
echo (git rev-parse --git-dir ^/dev/null)
|
||||
echo (git rev-parse --git-dir ^/dev/null)
|
||||
end
|
||||
|
||||
function __fish_git_prompt_validate_chars --description "__fish_git_prompt helper, checks char variables"
|
||||
|
||||
@@ -68,6 +68,7 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
|
||||
bind \cf forward-char
|
||||
bind \cb backward-char
|
||||
bind \ct transpose-chars
|
||||
bind \et transpose-words
|
||||
bind \e\x7f backward-kill-word
|
||||
bind \eb backward-word
|
||||
bind \ef forward-word
|
||||
|
||||
@@ -31,7 +31,7 @@ function funced --description 'Edit function definition'
|
||||
set -e argv[1]
|
||||
end
|
||||
|
||||
if begin; set -q funcname[2]; or not test "$funcname[1]"; end
|
||||
if test (count $funcname) -ne 1
|
||||
set_color red
|
||||
_ "funced: You must specify one function name
|
||||
"
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
if test (uname) = Darwin
|
||||
function prompt_pwd --description "Print the current working directory, shortend to fit the prompt"
|
||||
echo $PWD | sed -e "s|^$HOME|~|" -e 's|^/private||' -e 's-\([^/]\)[^/]*/-\1/-g'
|
||||
echo $PWD | sed -e "s|^$HOME|~|" -e 's|^/private||' -e 's-\([^/.]\)[^/]*/-\1/-g'
|
||||
end
|
||||
else
|
||||
function prompt_pwd --description "Print the current working directory, shortend to fit the prompt"
|
||||
echo $PWD | sed -e "s|^$HOME|~|" -e 's-\([^/]\)[^/]*/-\1/-g'
|
||||
echo $PWD | sed -e "s|^$HOME|~|" -e 's-\([^/.]\)[^/]*/-\1/-g'
|
||||
end
|
||||
end
|
||||
|
||||
17
wildcard.cpp
17
wildcard.cpp
@@ -217,12 +217,12 @@ static bool wildcard_complete_internal(const wcstring &orig,
|
||||
debug(2, L"Got null string on line %d of file %s", __LINE__, __FILE__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool has_match = false;
|
||||
string_fuzzy_match_t fuzzy_match(fuzzy_match_exact);
|
||||
const bool at_end_of_wildcard = (*wc == L'\0');
|
||||
const wchar_t *completion_string = NULL;
|
||||
|
||||
|
||||
// Hack hack hack
|
||||
// Implement EXPAND_FUZZY_MATCH by short-circuiting everything if there are no remaining wildcards
|
||||
if ((expand_flags & EXPAND_FUZZY_MATCH) && ! at_end_of_wildcard && ! wildcard_has(wc, true))
|
||||
@@ -231,7 +231,7 @@ static bool wildcard_complete_internal(const wcstring &orig,
|
||||
if (fuzzy_match.type != fuzzy_match_none)
|
||||
{
|
||||
has_match = true;
|
||||
|
||||
|
||||
/* If we're not a prefix or exact match, then we need to replace the token. Note that in this case we're not going to call ourselves recursively, so these modified flags won't "leak" except into the completion. */
|
||||
if (match_type_requires_full_replacement(fuzzy_match.type))
|
||||
{
|
||||
@@ -247,9 +247,10 @@ static bool wildcard_complete_internal(const wcstring &orig,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Maybe we satisfied the wildcard normally */
|
||||
if (! has_match) {
|
||||
if (! has_match)
|
||||
{
|
||||
bool file_has_leading_dot = (is_first && str[0] == L'.');
|
||||
if (at_end_of_wildcard && ! file_has_leading_dot)
|
||||
{
|
||||
@@ -264,7 +265,7 @@ static bool wildcard_complete_internal(const wcstring &orig,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (has_match)
|
||||
{
|
||||
/* Wildcard complete */
|
||||
@@ -281,7 +282,7 @@ static bool wildcard_complete_internal(const wcstring &orig,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (desc_func && ! (expand_flags & EXPAND_NO_DESCRIPTIONS))
|
||||
if (desc_func && !(expand_flags & EXPAND_NO_DESCRIPTIONS))
|
||||
{
|
||||
/*
|
||||
A description generating function is specified, call
|
||||
@@ -299,7 +300,7 @@ static bool wildcard_complete_internal(const wcstring &orig,
|
||||
append_completion(out, out_completion, out_desc, flags, fuzzy_match);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (*wc == ANY_STRING)
|
||||
{
|
||||
bool res=false;
|
||||
|
||||
Reference in New Issue
Block a user