Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 ~/.bashrc 中有这个函数,用于从终端创建一个永久别名:
function permalias () { alias "$*"; echo alias "$*" >> ~/.bashrc }
问题是它没有考虑到我正在为其创建别名的命令中可能有空格,所以permalias ll='ls -l'下次我打开终端时类似的东西将无法正常工作。
permalias ll='ls -l'
如何让它发挥作用?
只需将引号添加到 ~/.bashrc:
echo alias "'$*'" >> ~/.bashrc