在不关闭MacOS的情况下重启终端 [英] Restart terminal without closing on MacOS
问题描述
如何在不关闭窗口的情况下重新启动当前的MacOS终端会话?
How to restart my current MacOS terminal session without closing the window?
在Linux中,我使用 exec bash
,但在此环境中不起作用.我对 .bash_profile
进行了一些更改(提示,别名等),而无需关闭并再次打开.
In Linux I use exec bash
but it does not work in this environment. I made a few changes to the .bash_profile
(prompt, alias etc) I would like to see without closing it and opening again.
预先感谢
推荐答案
只需键入以下命令:
exec bash -l
我想应该这样做.
对于 zsh
,
exec zsh -l
这是必需的,因为默认情况下, macOS
上的每个shell都是登录shell.
This is needed because every shell on macOS
by default is a login shell.
仅仅编写 exec bash
会将当前的shell替换为非登录shell,这与关闭并重新打开终端的效果不同.
Justing writing exec bash
would replace the current shell with a non-login shell which is not the same effect as closing and re-opening the terminal.
exec
将使新的 bash -l </code>进程替换当前的shell.如果不使用
exec
,则 bash -l </code>将在当前shell上生成一个新shell,使
$ SHLVL
递增.
这篇关于在不关闭MacOS的情况下重启终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!