Interactive features
此内容尚不支持你的语言。
Line editing
Section titled “Line editing”grfsh uses emacs style keys by default. Run set -o vi for vi mode.
| Key | Action |
|---|---|
| Right arrow or Ctrl-F at the end of the line | accept the autosuggestion |
| Tab | complete |
| Ctrl-R | search history |
| Ctrl-C | cancel the line, or stop the running command |
| Ctrl-Z | stop the running command, then fg or bg |
| Ctrl-D | exit on an empty line |
bindkey key action changes a binding and bindkey -l lists the actions. bindkey -s '^G' 'git status\n' binds a key to text.
Autosuggestions and highlighting
Section titled “Autosuggestions and highlighting”As you type, grfsh shows the most recent matching history entry in a dim color. Commands are highlighted green when they exist and red when they do not, and strings, variables, options and operators each get their own color. Set NO_COLOR=1 to turn all colors off.
Completion
Section titled “Completion”Tab completes commands, builtins, functions, aliases, paths and variables, and understands a few common tools:
git: subcommands, then branches and tags forcheckout,switch,merge,rebaseand similar commandsssh,mosh,ping: hosts from~/.ssh/configandknown_hosts, andscp,rsync,sftpcompletehost:make: targets from the Makefilecargo: subcommands, including installedcargo-*toolscd,z,pushd: directories onlyfg,bg,kill: job numbers after%
Add your own with complete:
complete -W 'start stop restart status' svccomplete -C 'kubectl get ns -o name | cut -d/ -f2' knscomplete -d mycdcomplete -f myeditDirectory jumping
Section titled “Directory jumping”z jumps to the directory you visit most that matches all of its arguments:
z proj # ~/work/projectz go fast # ~/Work/goRustlyFastz -l proj # list matches with scoresTyping a directory name on its own changes to it. cd -, pushd, popd and dirs work as in bash.
History
Section titled “History”History is shared between sessions through ~/.grfsh_history. !!, !$, !n, !-n and !prefix expand when you press Enter. history --table shows the command log, with times, durations and exit statuses:
history --table | where status ne 0 | first 10history --table | where duration gt 5 | sort-by duration -rMistyped commands
Section titled “Mistyped commands”When a command is not found, grfsh suggests the closest name:
$ gti statusgrfsh: gti: command not found, did you mean 'git'?Abbreviations
Section titled “Abbreviations”Abbreviations expand when you press Enter, so your history keeps the full command:
abbr gco 'git checkout'abbr gp 'git push'abbr -e gp # removeabbr # listsleep 60 & # [1] 12345jobsfg %1bgwaitkill %1Functions named precmd, preexec and chpwd, or any function listed in the arrays precmd_functions, preexec_functions and chpwd_functions, run before each prompt, before each command line, and after the directory changes.
precmd() { printf '\033]0;%s\007' "${PWD##*/}"; }chpwd() { [[ -f .nvmrc ]] && nvm use; }