V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
jiyinyiyong
V2EX  ›  自言自语

cd 用来日常操作太丑陋了, 我要写个书签功能

  •  
  •   jiyinyiyong · 2012-10-14 19:17:29 +08:00 · 449 次点击
    这是一个创建于 4217 天前的主题,其中的信息可能已经有所发展或是发生改变。
    用 Node 写了个粗糙的命令, 现在至少能动做了
    https://github.com/jiyinyiyong/cd-link
    Bash 部分实在太难受了, 和同学一起想办法凑了很多次才成功的..
    要强大 Bash 大概真的能很强大, 的对于我这样的用户来说真设计太恶心了
    下面是一些演示:

    ➤➤ g -l
    cd-link: /home/chen/code/cd-link
    ➤➤ pwd
    /home/chen/code/cd-link
    ➤➤ g -l
    cd-link: /home/chen/code/cd-link
    ➤➤ g home /home/chen/
    'home' -> '/home/chen/' saved!
    ➤➤ g -l
    cd-link: /home/chen/code/cd-link
    home: /home/chen/
    ➤➤ g home
    code/ data/ desk/ dl/ doc/ kit/ music/ pic/ pub/ tmp/ video/ zjut/
    ∮ 12 /home/chen
    ➤➤ g nginx /etc/nginx/
    'nginx' -> '/etc/nginx/' saved!
    ➤➤ g code /home/chen/code/
    'code' -> '/home/chen/code/' saved!
    ➤➤ g nginx
    fastcgi.conf fastcgi_params koi-utf koi-win mime.types nginx.conf scgi_params uwsgi_params win-utf
    ∮ 9 /etc/nginx
    ➤➤ g -l
    cd-link: /home/chen/code/cd-link
    home: /home/chen/
    nginx: /etc/nginx/
    code: /home/chen/code/
    ➤➤ g demo /var/lib/mongodb/
    'demo' -> '/var/lib/mongodb/' saved!
    ➤➤ g dem
    link 'dem' not found!
    ➤➤ g demo
    bash: cd: /var/lib/mongodb/: Permission denied
    fastcgi.conf fastcgi_params koi-utf koi-win mime.types nginx.conf scgi_params uwsgi_params win-utf
    ∮ 9 /etc/nginx
    ➤➤ g -d demo
    removed link 'demo'
    ➤➤ g -l
    cd-link: /home/chen/code/cd-link
    home: /home/chen/
    nginx: /etc/nginx/
    code: /home/chen/code/
    ➤➤

    我使用 Node 处理数据书签映射的, 平台兼容性很差吧
    但我想这个思路在服务器段可以借鉴..
    就是用 Bash 调用外部程序, 然后形成 cd 跳转功能
    因为直接在外部程序使用 cd 是无法起效的, 烦了我好久... >_<

    代码比较烂, 如果有高人弄个 C 的版本 Patch 下 Bash 就好了
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2224 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 07:47 · PVG 15:47 · LAX 00:47 · JFK 03:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.