mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-22 15:35:43 +08:00
Resolve #30: omf doctor command
In order to pro-actively diagnose an issue on someone's computer, a `omf doctor' command is being added. This command will initially check errors that could cause a theme to not be loaded, but in the future more checks are going to be added to prevent issues from being created for problems that are fixable by the Oh My Fish user alone.
This commit is contained in:
parent
05f6691479
commit
bc0d4847e8
|
@ -86,9 +86,9 @@ Add a new package. To add a theme use `omf submit` _`themes/<name>`_ _`<url>`_.
|
|||
|
||||
Make sure to [send us a PR][omf-pulls-link] to update the registry.
|
||||
|
||||
#### `omf query` _`<variable name>`_
|
||||
#### `omf doctor`
|
||||
|
||||
Use to inspect all session variables. Useful to dump _path_ variables like `$fish_function_path`, `$fish_complete_path`, `$PATH`, etc.
|
||||
Use to troubleshoot before [opening an issue][omf-issues-new].
|
||||
|
||||
#### `omf destroy`
|
||||
|
||||
|
@ -129,3 +129,5 @@ Oh My Fish uses an advanced and well defined plugin architecture to ease plugin
|
|||
[contributors]: https://github.com/oh-my-fish/oh-my-fish/graphs/contributors
|
||||
|
||||
[omf-pulls-link]: https://github.com/oh-my-fish/oh-my-fish/pulls
|
||||
|
||||
[omf-issues-new]: https://github.com/oh-my-fish/oh-my-fish/issues/new
|
||||
|
|
|
@ -71,15 +71,6 @@ rm -rf "$fish_path"
|
|||
```
|
||||
|
||||
|
||||
## I changed my prompt with `fish_config` and now I can't get my Oh My Fish theme's prompt back, what do I do?
|
||||
|
||||
`fish_config` persists the prompt to `~/.config/fish/functions/fish_prompt.fish`. That file gets loaded _after_ the Oh My Fish theme, therefore it takes precedence over the Oh My Fish theme's prompt. To restore your Oh My Fish theme prompt, simply remove that file by running:
|
||||
|
||||
```
|
||||
rm ~/.config/fish/functions/fish_prompt.fish
|
||||
```
|
||||
|
||||
|
||||
## How do I use fish as my default shell?
|
||||
|
||||
Add Fish to `/etc/shells`:
|
||||
|
|
|
@ -70,16 +70,6 @@ rm -rf "$fish_path"
|
|||
```
|
||||
|
||||
|
||||
## 我使用 `fish_config` 修改了自己的 prompt,现在我无法恢复 Oh My Fish 主题的 prompt,我该怎么办?
|
||||
|
||||
`fish_config` 默认会使用 `~/.config/fish/functions/fish_prompt.fish` 设置 prompt,该文件在 Oh My Fish 主题启用后加载,
|
||||
它拥有高优先级来覆盖 Oh My Fish 主题的 prompt,如果你要恢复主题的 prompt,最简单的方法就是删除该文件:
|
||||
|
||||
```
|
||||
rm ~/.config/fish/functions/fish_prompt.fish
|
||||
```
|
||||
|
||||
|
||||
## 如何把 fish 设置为我默认的 shell?
|
||||
|
||||
添加 Fish 到 `/etc/shells`:
|
||||
|
|
|
@ -71,9 +71,9 @@ Oh My Fish 自带的辅助命令工具 `omf` 可以帮助你快速获取安装
|
|||
新插件或新主题需要托管于 Git 仓库,上面命令 url 需要输入 git 仓库的 url 地址。
|
||||
此命令仅仅是把 git 仓库地址保存与 Oh My Fish 的 db 数据库,同时还需要[提交 PR][omf-pulls-link]让组织把你的插件或主题归于框架。
|
||||
|
||||
#### `omf query` _`<variable name>`_
|
||||
#### `omf doctor`
|
||||
|
||||
用于查看所有会话的变量。用于查看调试类似 _PATH_ 变量,比如 `$fish_function_path`,`$fish_complete_path` 等。
|
||||
使用前[开馆问题][omf-issues-new] 解决。
|
||||
|
||||
#### `omf destroy`
|
||||
|
||||
|
@ -116,3 +116,5 @@ Oh My Fish 使用了友好的插件架构能够简化插件的开发,其中包
|
|||
[contributors]: https://github.com/oh-my-fish/oh-my-fish/graphs/contributors
|
||||
|
||||
[omf-pulls-link]: https://github.com/oh-my-fish/oh-my-fish/pulls
|
||||
|
||||
[omf-issues-new]: https://github.com/oh-my-fish/oh-my-fish/issues/new
|
||||
|
|
24
pkg/omf/cli/omf.doctor.fish
Normal file
24
pkg/omf/cli/omf.doctor.fish
Normal file
|
@ -0,0 +1,24 @@
|
|||
function __omf.doctor.theme
|
||||
if test -e ~/.config/fish/functions/fish_prompt.fish
|
||||
echo (omf::err)"Warning: "(omf::off)(omf::em)"fish_prompt.fish"(omf::off)" is overridden."
|
||||
echo (omf::em)" fish_config"(omf::off)" command persists the prompt to "(omf::em)"~/.config/fish/functions/fish_prompt.fish"(omf::off)
|
||||
echo " That file takes precedence over Oh My Fish's themes. Remove the file to fix it:"
|
||||
|
||||
echo (omf::em)" rm ~/.config/fish/functions/fish_prompt.fish"(omf::off)
|
||||
echo
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
function omf.doctor
|
||||
__omf.doctor.theme; or set -l doctor_failed
|
||||
|
||||
if set -q doctor_failed
|
||||
echo "If everything you use Oh My Fish for is working fine, please don't worry and just ignore the warnings. Thanks!"
|
||||
else
|
||||
echo (omf::em)"Your shell is ready to swim."(omf::off)
|
||||
end
|
||||
end
|
|
@ -35,6 +35,14 @@ function omf.help -a command
|
|||
omf destroy
|
||||
"
|
||||
|
||||
case "doctor"
|
||||
echo \n"\
|
||||
Troubleshoot Oh My Fish.
|
||||
|
||||
"(omf::dim)"Usage:"(omf::off)"
|
||||
omf doctor
|
||||
"
|
||||
|
||||
case "i" "install" "get"
|
||||
echo \n"\
|
||||
Install packages.
|
||||
|
@ -69,19 +77,6 @@ function omf.help -a command
|
|||
omf new theme mytheme
|
||||
"
|
||||
|
||||
case "q" "query"
|
||||
echo \n"\
|
||||
Query environment variables.
|
||||
|
||||
"(omf::dim)"Usage:"(omf::off)"
|
||||
omf query ["(omf::em)"<name>"(omf::off)"] Query environment variables
|
||||
|
||||
"(omf::dim)"Examples:"(omf::off)"
|
||||
omf query
|
||||
omf query path
|
||||
omf query version
|
||||
"
|
||||
|
||||
case "r" "rm" "remove" "uninstall"
|
||||
echo \n"\
|
||||
Remove a theme or package.
|
||||
|
@ -148,8 +143,8 @@ function omf.help -a command
|
|||
"(omf::em)"c"(omf::off)"d Change directory to plugin/theme directory.
|
||||
"(omf::em)"n"(omf::off)"ew Create a new package from a template.
|
||||
"(omf::em)"s"(omf::off)"ubmit Submit a package to the registry.
|
||||
"(omf::em)"q"(omf::off)"uery Query environment variables.
|
||||
"(omf::em)"destroy"(omf::off)" Uninstall Oh My Fish.
|
||||
"(omf::em)"doctor"(omf::off)" Troubleshoot Oh My Fish.
|
||||
"(omf::em)"help"(omf::off)" Shows help about a specific action.
|
||||
|
||||
"(omf::dim)"Options:"(omf::off)"
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
function omf.query_env
|
||||
function __omf.print_pretty_path -a path
|
||||
printf "%s\n" $path \
|
||||
| sed "s|$HOME|"(omf::em)"~"(omf::off)"|g" \
|
||||
| sed "s|/|"(omf::em)"/"(omf::off)"|g"
|
||||
end
|
||||
|
||||
if not set -q argv[1]
|
||||
for var in (set)
|
||||
echo (omf::dim)(echo $var | awk '{ printf $1"\n"; }')(omf::off)
|
||||
echo (omf::em)(__omf.print_pretty_path (echo $var | awk '{$1=""; print $0}'))(omf::off)
|
||||
end
|
||||
else
|
||||
for key in $$argv[1]
|
||||
__omf.print_pretty_path $key
|
||||
end
|
||||
end
|
||||
end
|
|
@ -42,17 +42,8 @@ function omf -d "Oh My Fish"
|
|||
case "-v*" "--v*"
|
||||
omf.version
|
||||
|
||||
case "q" "query"
|
||||
switch (count $argv)
|
||||
case 1
|
||||
omf.query_env
|
||||
case 2
|
||||
omf.query_env "$argv[2]"
|
||||
case "*"
|
||||
echo (omf::err)"Invalid number of arguments"(omf::off) 1^&2
|
||||
echo "Usage: $_ "(omf::em)"$argv[1]"(omf::off)" [<variable name>]" 1^&2
|
||||
return $OMF_INVALID_ARG
|
||||
end
|
||||
case "doctor"
|
||||
omf.doctor
|
||||
|
||||
case "-h*" "--h*" "help"
|
||||
if test (count $argv) -eq 1
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
set -l return_code 0
|
||||
|
||||
set commands "omf help" "omf query PATH" "omf query fish_function_path" "omf install apt"
|
||||
set commands "omf help" "omf doctor" "omf install apt"
|
||||
for cmd in $commands
|
||||
echo \$ $cmd
|
||||
if not eval $cmd
|
||||
|
|
Loading…
Reference in New Issue
Block a user