Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
funagi
V2EX  ›  Linux

Mintty(Cygwin)快速定位目录的问题

  •  
  •   funagi ·
    funagi · Sep 29, 2012 · 10206 views
    This topic created in 5152 days ago, the information mentioned may be changed or developed.
    目的是实现Windows右键菜单“在此处打开Cygwin”。


    网上搜到的都是使用cygwin bash启动,如下:
    %Cygwin%\bin\bash -login -c "cd '%1'; exec bash -rcfile ~/.bashrc"


    我尝试从Mintty(%Cygwin%\bin\mintty)启动,但没成功,试了半天,得到了一个买一送一的结果:

    %Cygwin%\bin\bash -login -c "cd '%1'; mintty"

    这显然不是我要的,因为多了一个多余的bash窗口。


    请问有没有办法直接从mintty.exe启动并定位到指定目录,谢谢了。


    P.S.找不到更合适的节点了……
    7 replies  •  1970-01-01 08:00:00 +08:00
    wontoncc
    wontoncc
    Sep 29, 2012❤️2
    1
    我的方法:
    cygwin-here.bat:

    @echo off
    set _T=%cd%
    set _V=%1
    E:
    chdir E:\cygwin\bin
    bash --login -i


    ~/.bash_profile:

    export _T=${_T//\\//}
    if [[ $_T == "" ]]; then
    export _T=~
    fi
    cd "$_T"
    export _V=${_V//\\//}
    if [[ $_V != "" ]]; then
    vim "$_V"
    fi

    思路是传递个环境变量,顺便实现了传递给 vim 方便编辑。
    借助 Listary 在当前目录运行 bat 的手段。
    wontoncc
    wontoncc
    Sep 29, 2012
    2
    注意一下,缩进坏了…
    windedge
    windedge
    Sep 30, 2012
    3
    没记错的话,可以使用chere添加
    haohaolee
    haohaolee
    Sep 30, 2012
    4
    什么cmd.exe mintty console2都弱爆了,我用ConEmu这种事会随便跟别人说吗
    jkeylu
    jkeylu
    Sep 30, 2012❤️2
    5
    我是这样的
    D:\cygwin\bin\mintty -i /Cygwin-Terminal.ico -e /bin/bash --login -i -c "cd '%1';exec bash"
    funagi
    funagi
    OP
    Sep 30, 2012
    6
    @wontoncc 传递环境变量这个思路不错,mark。

    @jkeylu 完美解决了,thx。P.S.执行两次bash有点郁闷囧
    funagi
    funagi
    OP
    Sep 30, 2012
    7
    @jkeylu 刚刚发现这样子没法Tab键补全~/.ssh/config和/etc/hosts中主机名;
    默认情况下是可以补全的;
    一般我定位到很长的路径下,除了一些麻烦的操作外,最主要的还是使用scp和sftp,而这两个正好需要到主机名配置。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1449 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 16:07 · PVG 00:07 · LAX 08:07 · JFK 11:07
    ♥ Do have faith in what you're doing.