开发者

ksh alias or function that does "setTermName blah"

开发者 https://www.devze.com 2023-02-09 15:29 出处:网络
I have the following line: echo -ne \"\\033]开发者_如何学Python0;blah\\007\" that correctly sets the term name to blah. But if I place that line within a function, as in:

I have the following line:

echo -ne "\033]开发者_如何学Python0;blah\007"

that correctly sets the term name to blah. But if I place that line within a function, as in:

setTermName()
{
  echo -ne "\033]0;blah\007"
}

it doesn't work anymore. I guess escape sequences are not treated correctly within the function. So my question could be reformulated as: How do you use escape sequences within a function?

I only want to be able to do setTermName foo from command line.


You invoke that echo command from interactive ksh also? Are you sure it understands -ne? It's not standard. Maybe use printf.

And you can try to use alias instead.

UPD: I've checked with AIX ksh, the following function worked:

set_tn()
{
  printf "\033]0;$1\007"
}
0

精彩评论

暂无评论...
验证码 换一张
取 消