Here s a less intrusive alternative by way of a simple alias:
alias lx= PATH="./bin:$PATH"
然后,可在任何具有<条码>的夹中使用<<>x>(L eX<>>>>>>。 a. 随身携带手印,不走路;例如,执行字母/bin/start-server
。 现有名录:
lx start-server
如果你希望根据 当地的可执行性使tab-completion,在您的巴什简介中添加以下内容(在OSX和LC/
# Install the custom tab-completion function defined below.
complete -F _complete_lx -- lx
# Command-completion function for lx: tab-completes the executables in
# the ./bin subfolder.
_complete_lx() {
# Set the directory in which to look for local executables.
local localExeDir= ./bin
# Get the current command-line token.
local token=${COMP_WORDS[$COMP_CWORD]}
local tokenLen=${#token}
# Find all local executables.
read -d -ra localExes < <(find "$localExeDir" -maxdepth 1 -type f -perm -a=x -exec basename -a {} +;)
# Filter the list of local executables
# based on the current command-line token.
# Turn case-insensitive matching temporarily on, if necessary.
local nocasematchWasOff=0
shopt nocasematch >/dev/null || nocasematchWasOff=1
(( nocasematchWasOff )) && shopt -s nocasematch
COMPREPLY=()
for localExe in "${localExes[@]}"; do
if [[ ${localExe:0:$(( tokenLen ))} == "$token" ]]; then
COMPREPLY+=( "$localExe" )
fi
done
# Restore state of nocasematch option, if necessary.
(( nocasematchWasOff )) && shopt -u nocasematch
}