[英]How to open a specific directory by default on start up of Command line?
When I start up command line, I want a specific directory to be opened by default without me having to type a long path.当我启动命令行时,我希望默认打开一个特定的目录,而无需输入长路径。
eg every time I open a terminal I want to be in directory ~/Desktop/foo/bar, so I want the following to happen例如,每次我打开终端时,我都想在目录 ~/Desktop/foo/bar 中,所以我希望发生以下情况
ctrl+alt+t
-> "terminal opens"
pwd
-> <yourPath>/Desktop/foo/bar
You can put this line at the end of your ~/.bashrc
file (or equivalent if you're using a different shell than bash):您可以将此行放在
~/.bashrc
文件的末尾(如果您使用的 shell 与 bash 不同,则可以等效):
cd <yourPath>/Desktop/foo/bar
Just add a command to the end of your .bashrc
只需在
.bashrc
末尾添加一个命令
cd /path/to/dir
If it's Ubuntu terminal you can edit your profile, tick run a custom command instead of my shell and make it:如果它是 Ubuntu 终端,您可以编辑您的配置文件,勾选运行自定义命令而不是我的 shell 并使其:
sh -c 'cd ~/Documents; exec "${SHELL:-sh}"'
What you might also consider if you want to move through directories quickly as bookmarks (almost), check out zsh which has a plugin called warp directory or if you don't want to make the leap to zsh, warp-drive fork .如果您想快速浏览目录作为书签(几乎),您可能还会考虑什么,请查看zsh ,它有一个名为warp 目录的插件,或者如果您不想跳转到 zsh, warp-drive fork 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.