【发布时间】:2016-08-18 17:19:28
【问题描述】:
下面的函数name 将使用函数myfunc 将当前工作目录名称设置为选项卡名称,但如果我将参数传递给name,那么它会将选项卡名称设置为传递的参数。
例如
name mytab [----> 这会将当前选项卡名称设置为 mytab]
我的 bashrc 如下:
function myfunc {
echo -n -e "\033]0;${PWD##*/}\007"
#--- some other thing ---
}
function name {
if [ "$1" ]
then
unset PROMPT_COMMAND
echo -ne "\033]0;${*}\007"
else
unset PROMPT_COMMAND
export PROMPT_COMMAND="history -n; history -w; history -c; history -r; myfunc;$PROMPT_COMMAND"
fi
}
name
所以如果我执行rm $(ls -t | head -1)
我收到错误/bin/rm: cannot lstat `\033[0m\033[0mReadme.txt\033[0m': No such file or directory
【问题讨论】:
-
你能显示
which ls的输出吗 -
which ls>>alias ls='ls --color'/bin/ls -
你可以测试命令
rm $(ls --color=no -t | head -1) -
是的。有效。谢谢。