我试图使用前景色更改 iterm2 的主色,但我发现它只影响部分文本而不影响所有文本:
如果我在命令行上启动 mysql,它也会采用与命令行颜色相同的颜色。
我该如何改变这些?
更新:白色 ansi 颜色与前景色相同:
我正在使用 zsh,这里是 y 文件中的提示配置.zshrc
:
PROMPT='%F{#9EC084}(${vcs_info_msg_0_})%F{#a0a1a0} %1d %F{#66C2CD}λ %F{#BCC4CF}'
我试图让这个脚本工作(它应该做的是在远程服务器的最后一个日志文件中搜索一个字符串):
ssh -i $ssh_key_file ubuntu@$1 -t "cd /path/to/logs; grep \"POST api/orders \" `ls -Art | grep info | tail -n 1` -A 2 | grep \"'store_id' => '$2'\" -B 1; bash --login"
这个脚本
`ls -Art | grep info | tail -n 1`
应该返回给我最后一个日志文件,这是一个例子,如果我在远程服务器上单独运行该脚本:
$ ls -Art | grep info | tail -n 1
info-2019-04-10.log
此外,如果我通过硬编码日志文件名来运行与上面完全相同的脚本,它就可以正常工作:
ssh -i $ssh_key_file ubuntu@$1 -t "cd /path/to/logs; grep \"POST api/orders \" info-2019-04-10.log -A 2 | grep \"'store_id' => '$2'\" -B 1; bash --login"
我能够将这个(查找最后一个日志文件)脚本嵌入到其他 shell 脚本中,并且运行良好,如下所示:
ssh -i $ssh_key_file ubuntu@$1 -t "cd /path/to/logs; grep $2 `ls -Art | grep info | tail -n 1`; bash --login"
我在原始脚本中做错了什么?
使用这个脚本
function totCreateOrder()
{
ssh -i "$ssh_key_file" ubuntu@"$1" -t<<EOF
cd /var/www/toters/storage/logs && grep "POST api/orders " "\$(ls -Art | grep info | tail -n 1)" -A 2 \
| grep "'store_id' => '"'$2'"'" -B 1
bash --login
EOF
}
正在返回这个奇怪的错误消息
totCreateOrder $prod1as 1006
Pseudo-terminal will not be allocated because stdin is not a terminal.
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-1067-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
74 packages can be updated.
0 updates are security updates.
New release '18.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
*** System restart required ***
我查看了该错误的含义并改为执行此操作
function totCreateOrder()
{
ssh -i $ssh_key_file ubuntu@$1 -t -t<<EOF
cd /var/www/toters/storage/logs && grep "POST api/orders " "\$(ls -Art | grep info | tail -n 1)" -A 2 \
| grep "'store_id' => '"'$2'"'" -B 1
EOF
}
但后来我收到此错误消息:
totCreateOrder $prod1as 1006
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-1067-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
74 packages can be updated.
0 updates are security updates.
New release '18.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
*** System restart required ***
Last login: Thu Apr 11 03:38:32 2019 from 185.81.141.32
1"$(ls -Art | grep info | tail -n 1)" -A 2 | grep "'store_id' => '"'1006'"'" -B
我正在逐行检查脚本。这在实现以下目标的意义上起作用:
ls -Art | grep info | tail -n 1
正确解析在远程服务器上运行此命令:grep "POST api/orders " "$(ls -Art | grep info | tail -n 1)" -A 2
函数测试(){ ssh -i $ssh_key_file ubuntu@$1 -t -t<
它返回了这个
test $prod1as
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-1067-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
74 packages can be updated.
0 updates are security updates.
New release '18.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
*** System restart required ***
Last login: Thu Apr 11 05:18:10 2019 from 185.81.141.85
ubuntu@ip-x-xx-xx:~$ cd /var/www/toters/storage/logs
-Art | grep info | tail -n 1)" -A 2 storage/logs$ grep "POST api/orders " "$(ls
[2019-04-11 04:10:39] production.INFO: POST api/orders [] []
[2019-04-11 04:10:39] production.INFO: array ( 'store_id' => '831', 'items' => array ( 0 => array ( 'additional_info' => '', 'addons' => array ( ), 'quantity' => 1, 'id' => 129369,
), 1 => array ( 'additional_info' => '', 'addons' => array ( ), 'quantity' => 1, 'id' => 133351, ), 2 => array ( 'additional_info' => '', 'addons' => ..
然而,当我像这样添加管道时,事情就坏了:
function test()
{
ssh -i $ssh_key_file ubuntu@$1 -t -t<<EOF
cd /var/www/toters/storage/logs
grep "POST api/orders " "\$(ls -Art | grep info | tail -n 1)" -A 2 | grep "'store_id' => '"'$2'"'" -B 1
EOF
}
它返回这个
$ test $prod1as 1006
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-1067-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
74 packages can be updated.
0 updates are security updates.
New release '18.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
*** System restart required ***
Last login: Thu Apr 11 05:33:22 2019 from 185.81.141.85
ubuntu@ip-10-0-1-39:~$ cd /var/www/toters/storage/logs
-Art | grep info | tail -n 1)" -A 2 | grep "'store_id' => '"'1006'"'" -B 1"$(ls