V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
whnzy
V2EX  ›  Vim

shell 怎么显示 vim 的后台状态?

  •  
  •   whnzy · Jun 24, 2016 · 4071 views
    This topic created in 3594 days ago, the information mentioned may be changed or developed.

    使用 vim 的时候总是会切入后台

    • :sh
    • c-z

    不管使用哪种方法都可以使用 exit 来回到 vim ,但是有时就会忘记是否有没有 vim 在后台挂起,所以需要在 shell 中显示。

    所以写下了下面的脚本

    $PS1_BAK="$PS1"
    if [ $MYVIMRC ]; then
        $PS1="_vim"$PS1
    else
        $PS1=$PS1_BAK
    fi
    

    但是并无什么卵用

    因为我用的 tmux ,还有个方法是在 tmux 中显示状态。

    大家有没有什么好的办法在 shell 中显示(zsh)?

    Supplement 1  ·  Jun 25, 2016

    附言居然收铜币,发的评论竟然不能删除。。。
    而且找不到加hastag的地方。。。
    而且评论中不知道为什么不显示图片

    已经搞定了,现在是这个样子的。

    我会反思下是不是我工作流程不够简洁的。

    whnzy
        1
    whnzy  
    OP
       Jun 24, 2016
    v2ex 怎么加 hastag
    morefreeze
        2
    morefreeze  
       Jun 24, 2016
    打个 fg 也费不了多少事吧
    当然忘了那就另说了
    rashawn
        3
    rashawn  
       Jun 24, 2016
    如果忘了 新 vim 打开同一个文件不是有提示吗 一般不会忘的吧 tmux 分三页 第一页一直是 nvim 如果是命令行 就敲 fg
    xuboying
        4
    xuboying  
       Jun 24, 2016 via Android
    exit 的时候会提醒你的
    ini
        5
    ini  
       Jun 24, 2016 via Android
    jobs
    whnzy
        6
    whnzy  
    OP
       Jun 24, 2016
    @xuboying 当我忘记是不是有 vim 的时候,我就会把 shell 给 exit 掉啊
    whnzy
        7
    whnzy  
    OP
       Jun 24, 2016
    @ini 可是能不能实时的显示在 shell 中
    whnzy
        8
    whnzy  
    OP
       Jun 24, 2016
    @rashawn 这个是一定的,但是我会忘记是否有开过 vim 了
    aisk
        9
    aisk  
       Jun 24, 2016
    写到 prompt 上比较醒目
    xuboying
        10
    xuboying  
       Jun 24, 2016
    可能的 AB 问题
    虽然可以有很多种办法解决你的 B 问题,
    但是不是你的工作流程太忙乱了,需要解决 A 问题比较好呢?
    hanxiV2EX
        11
    hanxiV2EX  
       Jun 24, 2016 via iPhone
    改掉后台 vim 的习惯,都用 tmux 了,要进去 shell 的话直接加个 pane,然后用完退出。
    whnzy
        12
    whnzy  
    OP
       Jun 24, 2016
    @xuboying 谢谢,可能是我的工作流程复杂,频繁的退出 vim
    c4pt0r
        13
    c4pt0r  
       Jun 25, 2016
    如果只是为了确定是不是由 vim 启动的 shell 的话, ps -f 看看父进程里有没有 vim 咯
    cxbig
        14
    cxbig  
       Jun 25, 2016
    tmux +1
    whnzy
        15
    whnzy  
    OP
       Jun 25, 2016
    不过已经弄好了。后台的时候是这样的 ![]( http://i4.piimg.com/4851/fbd8cdf50f8aa7ae.jpg)
    whnzy
        16
    whnzy  
    OP
       Jun 25, 2016
    不过已经弄好了。后台的时候是这样的 !()[ http://i4.piimg.com/4851/fbd8cdf50f8aa7ae.jpg]
    whnzy
        17
    whnzy  
    OP
       Jun 25, 2016
    skydiver
        18
    skydiver  
       Jun 25, 2016 via iPad
    C-z 没法用 exit 回到 vim 吧,需要 fg 才能回去
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5082 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 80ms · UTC 05:39 · PVG 13:39 · LAX 22:39 · JFK 01:39
    ♥ Do have faith in what you're doing.