pull/1518/head
Hongyi Zhao 2020-03-25 16:42:10 +08:00
commit f28ce6c2de
6 changed files with 52 additions and 10 deletions

View File

@ -18,6 +18,7 @@ function _set_pkg_aliases()
alias kcdn='kubectl describe node' alias kcdn='kubectl describe node'
alias kcgpan='kubectl get pods --all-namespaces' alias kcgpan='kubectl get pods --all-namespaces'
alias kcgdan='kubectl get deployments --all-namespaces' alias kcgdan='kubectl get deployments --all-namespaces'
alias kcnetshoot='kubectl run --generator=run-pod/v1 netshoot-$(uuidgen | tr A-Z a-z | sed 's/-//g') --rm -i --tty --image nicolaka/netshoot -- /bin/bash'
fi fi
} }

View File

@ -53,7 +53,7 @@ __vagrantinvestigate() {
_vagrant() { _vagrant() {
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="snapshot box connect destroy docker-logs docker-run global-status halt help init list-commands login package plugin provision rdp reload resume rsync rsync-auto share ssh ssh-config status suspend up version" commands="box cloud destroy global-status halt help hostmanager init login package plugin port powershell provision push rdp reload resume scp snapshot ssh ssh-config status suspend up upload validate vbguest version winrm winrm-config"
if [ $COMP_CWORD == 1 ] if [ $COMP_CWORD == 1 ]
then then
@ -91,12 +91,12 @@ _vagrant() {
return 0 return 0
;; ;;
"box") "box")
box_commands="add help list remove repackage" box_commands="add list outdated prune remove repackage update"
COMPREPLY=($(compgen -W "${box_commands}" -- ${cur})) COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
return 0 return 0
;; ;;
"plugin") "plugin")
plugin_commands="install license list uninstall update" plugin_commands="expunge install license list repair uninstall update"
COMPREPLY=($(compgen -W "${plugin_commands}" -- ${cur})) COMPREPLY=($(compgen -W "${plugin_commands}" -- ${cur}))
return 0 return 0
;; ;;
@ -105,7 +105,7 @@ _vagrant() {
return 0 return 0
;; ;;
"snapshot") "snapshot")
snapshot_commands="back delete go list take" snapshot_commands="delete list pop push restore save"
COMPREPLY=($(compgen -W "${snapshot_commands}" -- ${cur})) COMPREPLY=($(compgen -W "${snapshot_commands}" -- ${cur}))
return 0 return 0
;; ;;
@ -135,13 +135,29 @@ _vagrant() {
esac esac
;; ;;
"snapshot") "snapshot")
if [ "$prev" == "go" ]; then if [ "$prev" == "restore" ]; then
local snapshot_list=$(vagrant snapshot list | awk '/Name:/ { print $2 }') COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
return 0 return 0
fi fi
;; ;;
esac esac
fi fi
if [ $COMP_CWORD == 4 ]
then
action="${COMP_WORDS[COMP_CWORD-3]}"
prev="${COMP_WORDS[COMP_CWORD-2]}"
case "$action" in
"snapshot")
if [ "$prev" == "restore" ]; then
local snapshot_list="$(vagrant snapshot list ${cur} 2>/dev/null | awk '{ORS=" "} /==>/ {next} {print}')"
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
return 0
fi
;;
*)
;;
esac
fi
} }
complete -F _vagrant vagrant complete -F _vagrant vagrant

View File

@ -123,7 +123,7 @@ function preexec_install () {
# Finally, install the actual traps. # Finally, install the actual traps.
if [[ ! -z "${PROMPT_COMMAND// }" ]]; then if [[ ! -z "${PROMPT_COMMAND// }" ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND};preexec_invoke_cmd" PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n'"preexec_invoke_cmd"
else else
PROMPT_COMMAND="preexec_invoke_cmd" PROMPT_COMMAND="preexec_invoke_cmd"
fi fi

View File

@ -0,0 +1,18 @@
cite about-plugin
about-plugin 'load goenv, if you are using it'
# Don't modify the environment if we can't find the tool:
# - Check if in $PATH already
# - Check if installed manually to $HOME
_command_exists goenv ||
[[ -x "$HOME/.goenv/bin/goenv" ]] ||
return
# Set GOENV_ROOT, if not already set
export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}"
# Add GOENV_ROOT/bin to PATH, if that's where it's installed
[[ -x "$HOME/.goenv/bin/goenv" ]] && pathmunge "$GOENV_ROOT/bin"
# Initialize goenv
eval "$(goenv init - bash)"

View File

@ -68,6 +68,8 @@ NVM_THEME_PROMPT_SUFFIX='|'
RVM_THEME_PROMPT_PREFIX=' |' RVM_THEME_PROMPT_PREFIX=' |'
RVM_THEME_PROMPT_SUFFIX='|' RVM_THEME_PROMPT_SUFFIX='|'
THEME_SHOW_RUBY_PROMPT=${THEME_SHOW_RUBY_PROMPT:=true}
THEME_SHOW_USER_HOST=${THEME_SHOW_USER_HOST:=false} THEME_SHOW_USER_HOST=${THEME_SHOW_USER_HOST:=false}
USER_HOST_THEME_PROMPT_PREFIX='' USER_HOST_THEME_PROMPT_PREFIX=''
USER_HOST_THEME_PROMPT_SUFFIX='' USER_HOST_THEME_PROMPT_SUFFIX=''
@ -371,7 +373,9 @@ function chruby_version_prompt {
} }
function ruby_version_prompt { function ruby_version_prompt {
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)" if [[ "${THEME_SHOW_RUBY_PROMPT}" = "true" ]]; then
echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)"
fi
} }
function k8s_context_prompt { function k8s_context_prompt {

View File

@ -9,8 +9,11 @@ GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓"
GIT_THEME_PROMPT_PREFIX=" ${green}|" GIT_THEME_PROMPT_PREFIX=" ${green}|"
GIT_THEME_PROMPT_SUFFIX="${green}|" GIT_THEME_PROMPT_SUFFIX="${green}|"
VIRTUALENV_THEME_PROMPT_PREFIX="${green}"
VIRTUALENV_THEME_PROMPT_SUFFIX=""
function prompt_command() { function prompt_command() {
PS1="\n${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} " PS1="\n$(virtualenv_prompt)${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
} }
safe_append_prompt_command prompt_command safe_append_prompt_command prompt_command