mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 11:31:15 -03:00
Merge branch 'master' into parsed
This commit is contained in:
@@ -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();
|
||||
@@ -1802,9 +1801,9 @@ static bool subsequence_in_string(const wcstring &seq, const wcstring &str)
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
51
reader.cpp
51
reader.cpp
@@ -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);
|
||||
}
|
||||
@@ -1635,7 +1635,7 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
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;
|
||||
@@ -1652,7 +1652,7 @@ static bool handle_completions(const std::vector<completion_t> &comp)
|
||||
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;
|
||||
|
||||
@@ -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 */
|
||||
@@ -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
|
||||
|
||||
@@ -249,7 +249,8 @@ 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)
|
||||
{
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user