【问题标题】:Autojump on mac OS X returning path, but not jumping to desired directory在 mac OS X 上自动跳转返回路径,但不跳转到所需目录
【发布时间】:2022-02-16 20:40:25
【问题描述】:

我在 OS X Yosemite 上遇到的问题:

autojump v22.2.4 (https://github.com/joelthelion/autojump),通过别名

j

返回我想跳转的路径,但不执行实际跳转。

sad 解决方法是复制返回的路径并将其添加到 cd 命令中。

j work   
/Users/peterlustig/Documents/workspace/
# now copy the resulting path manually
cd /Users/peterlustig/Documents/workspace/ 

问题在终端和 iterm2 中都存在。我遵循了安装后的说明

brew install autojump 

并添加了

[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh

到我的 ~/.bash_profile。

编辑:

jc work

让我跳转到我的“工作区”目录(在打印工作区目录的路径之后)。 现在,

有什么问题
j

?

【问题讨论】:

  • 光看网页有没有修改PROMPT_COMMAND的东西?
  • 我不知道...会在 ~/.bash_profile 中吗?
  • 如果你运行set -x; j work; set +x,你会得到什么输出?
  • output: + autojump work /Users/peterlustig/Documents/workspace + set +x // 问题依旧,没有跳转
  • 有什么解决办法吗?我遇到了同样的问题:(

标签: bash terminal osx-yosemite iterm2


【解决方案1】:

我已经成功了,我建议您执行以下操作:

  1. 检查你运行的是哪个shell:

    ps -op $$
    
    # im runnning
    PID   TTY        TIME    CMD
    43977 ttys012    0:00.11 -bash
    
  2. 如果你喜欢我通过brew 安装,那么你可能添加了(有.sh 文件):

    [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
    

我正在运行 bash,但不知道要包含不同的 shell:

     # have a look in:
     /usr/local/etc

     # you should see mutliple shell scripts to include (depending on your env):
     autojump.bash -> ../Cellar/autojump/21.7.1/etc/autojump.bash
     autojump.sh -> ../Cellar/autojump/21.7.1/etc/autojump.sh
     autojump.zsh -> ../Cellar/autojump/21.7.1/etc/autojump.zsh
  1. 对我来说,没有/usr/local/etc/profile.d,只有/usr/local/etc。将命令更改为:

    # ~/.bash_profile
    # i append this as my last line, that seems to work
    [[ -s $(brew --prefix)/etc/autojump.bash ]] && . $(brew --prefix)/etc/autojump.bash
    
  2. 退出您的终端并登录,应该可以。

【讨论】:

    【解决方案2】:

    这对我有帮助 https://github.com/wting/autojump/issues/511#issuecomment-362142038:

    你必须先cd <dirname>,下次你打电话给j <dirname>时,自动跳转会为你记住它

    【讨论】:

      【解决方案3】:

      这个错误似乎存在于最新版本的 autojump(22.5.1) 中。 autojump 命令只打印目录路径,不改变目录。

      我做了以下事情 - 1.) 将以下行添加到我的 ~/.zshrc 文件中

      [[ -s `brew --prefix`/etc/autojump.sh ]] && . `brew --prefix`/etc/autojump.sh
      

      2.) 然后简单地创建一个别名,将自动跳转到cdcommand

      alias j=autojump | cd
      

      希望这对你们有用。

      【讨论】:

        【解决方案4】:

        我在 OSX 上使用 bash。它也不适合我。问题是我没有手动更改到任何目录。一旦我这样做了,它就会像宣传的那样工作。

        【讨论】:

          猜你喜欢
          • 2021-04-18
          • 2023-03-06
          • 1970-01-01
          • 2018-11-25
          • 1970-01-01
          • 1970-01-01
          • 2020-08-23
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多