简体   繁体   English

Bash-CD实例而不是子进程

[英]Bash - cd your instance rather than sub process

So I've created a bash script that takes argument and then (I want it to) cd me into a directory. 因此,我创建了一个带参数的bash脚本,然后(我希望它)将我cd到目录中。

It's not quite a case of cd /home/$1 for example, it's a bit more complex. 例如,它不是cd / home / $ 1的情况,它有点复杂。

The problem is (as I knew it would be) it's cding the sub process rather than my instance of bash. 问题是(正如我所知道的那样)它正在给子进程而不是我的bash实例添加代码。

Is there any way to apply it to my open bash? 有什么方法可以将其应用于我的公开bash吗?

Echo the desired directory, then create a bash alias as follows: 回显所需的目录,然后创建bash别名,如下所示:

alias jump="cd $(myscript.sh)"

It's the approach I use for autojump , and it works very well. 这是我用于自动跳转的方法,并且效果很好。

I guess this is another option for you 我想这是您的另一选择

favorite directory 最喜欢的目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM