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


1

我正在使用基于弹簧外壳的内部产品“shell”。当我按向上箭头来获取我的最后一个命令时,我得到(反向搜索)`':

检索最后一个命令适用于所有同事,所以我想知道我的.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.

任何人都可以给我任何关于可能导致这种奇怪行为的指示。


试试bash --norc
赛勒斯2014年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.