使用向上箭头时,会发生递归搜索而不是最后一个命令。

使用向上箭头时,会发生递归搜索而不是最后一个命令。

我正在使用基于 spring shell 的内部产品“shell”。当我按向上箭头获取最后一个命令时,我得到的却是 (reverse-i-search)`':

检索最后一个命令对我的所有同事都有效,所以我想知道我的 .bash_profile 或 .bash_functions 中是否存在一些设置导致这种奇怪的行为。

我的 .bash_functions 包含:

cwd3() {
typeset start=${PWD/${HOME}/\~}
typeset delete=${start%/*/*/*}
typeset partial=${start#${delete}/}
if [[ "${partial}" != /* && "${partial}" != \~* ]]
then
    partial="${partial}"
fi
echo "${partial}"
}

我的 .bash_profile 包含:

#!/bin/bash
echo running .bash_profile

if [ -f $HOME/.bash_functions ]; then
 . $HOME/.bash_functions
fi

if [ -f $HOME/.bash_prompt ]; then
. $HOME/.bash_prompt
fi

if [ -f $HOME/.git-completion ]; then
. $HOME/.git-completion
fi

function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}

function command_exists {
command -v $1 >/dev/null 2>&1
}

function find_cellar {
echo $(brew --cellar $1)/$(brew list --versions $1 | cut -d ' ' -f 2)
}

function find_libexec {
echo $(find_cellar $1)/libexec
}

# Set titles
PS1="\[$Green\]\u\[$Green\]@\[$Green\]\h\[$Green\]:\[$White\]\$(__cwd3)\[$Green\]\$(__git_ps1 ' (%s)')\[$Green\]\$ \[$IGreen\]"

# UNIX Exports
export EDITOR="subl -w"
export HISTCONTROL=erasedups
export HISTSIZE=10000
shopt -s histappend



#Set Java home for hadoop
if [ "$1" == "h" ];
then
echo "setting env up for hadoop"
export JAVA_HOME=$JAVA6_HOME
fi

#set java home for rti4t
if [ "$1" == "r" ];
then
echo "setting env up for RTI4T" 
export JAVA_HOME=$JAVA7_HOME
fi


if command_exists brew; then
export PATH=$(brew --prefix)/bin:$(brew --prefix)/sbin:$(brew --  prefix)/share/npm/bin:$PATH
fi

if command_exists rbenv; then
export RUBY_HOME=$(rbenv prefix)
export PATH=$RUBY_HOME/bin:$PATH
fi



# Enable bash completion
if command_exists brew; then
BASH_COMPLETION_PREFIX=$(brew --prefix)
fi
if [ -f $BASH_COMPLETION_PREFIX/etc/bash_completion ]; then
. $BASH_COMPLETION_PREFIX/etc/bash_completion
fi
if which rbenv &> /dev/null; then eval "$(rbenv init -)"; fi


#THIS MUST BE AT THE END OF THE FILE FOR GVM TO WORK!!!
[[ -s "/Users/duncwinn/.gvm/bin/gvm-init.sh" && ! $(which gvm-init.sh) ]] && source       "/Users/duncwinn/.gvm/bin/gvm-init.sh"

#THIS MUST BE AT THE END OF THE FILE FOR RVM / rbenv TO WORK!!!
eval "$(rbenv init -)"
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

有人能给我指点一下是什么导致了这种奇怪的行为吗?

相关内容