Naykcin
V2EX  ›  macOS

[请教] 各位有注意到 macOS 终端的数字快捷键定位目录这个功能吗?

  •  
  •   Naykcin · Jun 20, 2020 · 2602 views
    This topic created in 2154 days ago, the information mentioned may be changed or developed.

    一直没搞明白这个数字快捷键定位目录的功能是怎么一回事儿。。譬如说当前处于用户家目录,按下 1 会跳到 ~/Documents/Tools/exp/SMBGhost,按下 2 会跳到 ~/Documents/Tools/exp/SMBGhost_RCE_PoC 。

    但是如果从另一个目录下按下 1 或 2,指向的目录不再是上面指出的两个目录了,也就是说数字键和目录的指向性不是唯一的,而是动态的,看了半天没看出来啥规律,同时我也没有指定 alias 变量。

    各位有注意过吗?请教一下!

    命令行图片示例

    Supplement 1  ·  Jun 20, 2020

    感谢 @FuNn1esT

    原来这个功能是 oh-my-zsh 的特性,在描述文件中设置了 1 = "cd -",2 = "cd -2" 等等,即返回上次目录和返回上上次目录,以此类推。该功能与 macOS 终端并无关系,此帖终结。

    由 @FuNn1esT 提供的官方文档: https://github.com/ohmyzsh/ohmyzsh/blob/ea3e666e04bfae31b37ef42dfe54801484341e46/lib/directories.zsh#L12

    在终端下输入 alias 打印所有 alias: 图片

    3 replies    2020-06-20 17:40:12 +08:00
    FuNn1esT
        1
    FuNn1esT  
       Jun 20, 2020   ❤️ 1
    oh my zsh 自带的
    https://github.com/ohmyzsh/ohmyzsh/blob/ea3e666e04bfae31b37ef42dfe54801484341e46/lib/directories.zsh#L12
    你可以直 shell 接输入 alias 输出当前有哪些 alias
    MartinWu
        2
    MartinWu  
       Jun 20, 2020   ❤️ 1
    which 一下就知道了。
    hengstchon
        3
    hengstchon  
       Jun 20, 2020   ❤️ 1
    按 d 可以知道当前有哪些目录可以跳转。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4012 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 05:07 · PVG 13:07 · LAX 22:07 · JFK 01:07
    ♥ Do have faith in what you're doing.