我在 Windows 10 中使用基于 Ubuntu 14.04 构建的 Windows Linux 子系统。
➜ User lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
我使用以下方式安装 Fish:
sudo apt-add-repository ppa:fish-shell/release-2
sudo apt-get update
sudo apt-get install fish
和 oh-my-fish 使用:
curl -L http://get.oh-my.fish | fish
并且一切正常,但我对理解 fish shell 中的别名(函数)有疑问。
安装后fish
,oh-my-fish
我用它替换了默认bash
shell。现在,例如,当我ls
在终端中使用命令时,它会ls
作为 fish 别名(或 fish 函数)执行。
我理解我可以看到该函数是如何使用来实现的:
functions ls
在这种情况下,我有输出:
function ls --description 'List contents of directory'
set -l param --color=auto
if isatty 1
set param $param --indicator-style=classify
end
command ls $param $argv
end
并且我知道我可以使用 ubuntu 默认ls
命令command ls
或builtin ls
命令。
现在我需要找到实现此ls
别名和其他fish
别名(函数)的鱼函数文件的位置。
全部列表在这里http://pastebin.com/pSenBfWS.我使用命令获取此列表functions -n
(https://fishshell.com/docs/current/commands.html#functions)。
简而言之,我的问题是:“Ubuntu 14.04 中的 fish 功能文件在哪里?”
我有鱼版本 2.5.0
答案1
我认为我找到了部分回答回答我的问题。以下列出的是fish 和 oh-my-fish 内置函数我使用functions -n
命令获得(https://fishshell.com/docs/current/commands.html#functions):
# found in /usr/share/fish/functions:
N_
abbr
alias
cd
contains_seq
delete-or-exit
dirh
dirs
down-or-search
edit_command_buffer
eval
export
fish_clipboard_copy
fish_clipboard_paste
fish_config
fish_default_key_bindings
fish_default_mode_prompt
fish_fallback_prompt
fish_hybrid_key_bindings
fish_indent
fish_key_reader
fish_mode_prompt
fish_update_completions
fish_vi_cursor
fish_vi_key_bindings
fish_vi_mode
funced
funcsave
grep
help
history
hostname
isatty
la
ll
ls
man
math
nextd
nextd-or-forward-word
open
popd
prevd
prevd-or-backward-word
prompt_hostname
prompt_pwd
psub
pushd
realpath
seq
setenv
string
suspend
trap
type
umask
up-or-search
vared
// not found in /usr/share/fish/functions:
# all in /home/user/.local/share/omf/pkg/omf/functions/compat
refresh
available
# all in /home/user/.local/share/omf/pkg/fish-spec/functions
fish-spec
assert
assert.error_message
assert.expand_operator
# all of git_* group in /home/user/.local/share/omf/lib
git_ahead
git_branch_name
git_is_dirty
git_is_repo
git_is_staged
git_is_stashed
git_is_touched
git_untracked
# all of not git group in /home/user/.local/share/omf/lib
autoload
require
prompt_segments
// OMF:
omf # in /home/user/.local/share/omf/pkg/omf/functions
# all of omf.bundle.* group /home/user/.local/share/omf/pkg/omf/functions/bundle
omf.bundle.add
omf.bundle.install
omf.bundle.remove
# all of omf.check.* group in /home/user/.local/share/omf/pkg/omf/functions/util
omf.check.fish_prompt
omf.check.version
# all of omf.cli.* group in /home/user/.local/share/omf/pkg/omf/functions/cli
omf.cli.cd
omf.cli.channel
omf.cli.describe
omf.cli.destroy
omf.cli.doctor
omf.cli.help
omf.cli.install
omf.cli.list
omf.cli.new
omf.cli.reload
omf.cli.remove
omf.cli.search
omf.cli.theme
omf.cli.themes.list
omf.cli.update
omf.cli.version
# all in /home/user/.local/share/omf/pkg/omf/functions/core
omf.core.update
omf.destroy
omf.doctor
omf.channel.get
omf.channel.set
omf.reload
omf.version
omf.xdg.config_home
# all of omf.index.* group in /home/user/.local/share/omf/pkg/omf/functions/index
omf.index.path
omf.index.query
omf.index.repositories
omf.index.stat
omf.index.update
# all of omf.packages.* group in /home/user/.local/share/omf/pkg/omf/functions/packages
omf.packages.cd
omf.packages.install
omf.packages.list
omf.packages.name
omf.packages.new
omf.packages.path
omf.packages.remove
omf.packages.run_hook
omf.packages.update
omf.packages.valid_name
# all of omf.repo.* group in /home/user/.local/share/omf/pkg/omf/functions/repo
omf.repo.clone
omf.repo.pull
# in /home/user/.local/share/omf/pkg/omf/functions/themes
omf.theme.set
# that's functions I found in /home/user/.local/share/omf/pkg/omf/init.fish file
omf::dim
omf::em
omf::err
omf::off
omf::under
# that function I found in /home/user/.local/share/omf/init.fish file
fish_user_key_bindings
根本没找到:
. # yes, it's function too (use command: "functions ." to see)
fish_sigtrap_handler
答案2
我知道这是一个老问题,但刚刚才发现。如果我理解正确,你可能正在寻找 fish 函数的存储位置。如果是这样,它们位于~/.config/fish/functions