zserge / mucks

A tiny terminal session manager for Tmux, Screen and DVTM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dose mucks support mac os x 10.11?

violetcherry opened this issue · comments

In my mac os x 10.11,I git clone the repository into $HOME/Applications/soft/mucks,Then I enter the directory $HOME/Applications/soft/mucks and run ./mucks ~/myproject.mucksrc accodring the introduction from your blog,however I encounter these errors :
/usr/bin/awk: non-terminated string -X stuff ... at source line 106 in function mux_send source file ./mucks context is <<< ") mux("screen", "-p " wndindex " -X stuff " esc(text) >>> "
/usr/bin/awk: non-terminated string ))sc(text ... at source line 109 in function mux_send source file ./mucks
/usr/bin/awk: non-terminated string ))}c(text ... at source line 111 in function mux_send source file ./mucks
/usr/bin/awk: giving up
source line number 219
Cloud you give me some suggestion or solutions?Thank you!

I don't have a Mac on my side, so I can't check/fix it quickly.
At a first glance it looks like AWK is misinterpreting newlines inside quotes - it should continue reading until the closing quote, but it stops at newline.

  • Which AWK you are using? Gawk? Mawk? Busybox' awk?
  • Which muxer you are using? Tmux? Screen? DVTM?

@zserge I am so sorry to be late for replying.

  • I think awk in my mac os x is just awk not Gawk nor Mawk.
    which -a awk gets /usr/bin/awk , awk --version gets awk version 20070501, and man awk gets information which is almost similar with this website.
  • I test both Tmux and Screen, the error messages are the same just posted in the first comment.

Hm.. It turns out that other AWK implementations can't handle non-ascii symbols (Ctrl+M, which is a newline).
You may either remove lines 107..108 if you only want to support Tmux, or you may install Gawk which should handle Ctrl+M symbol well. A proper solution would be to use "\n" instead of Ctrl+M, but it breaks some mucksrc scripts in Screen (e.g. if you want to send some keys into vim running inside screen). Which means escaping should be done differently for different muxers, and it quickly becomes complicated.

@zserge,Thansk for your suggestion,I installed gawk in my system.After one month using,I have encountered some annoying situations.

First → tmux Can't attach the session when detaching the session.

With the .mucksrc file in the ~/Appilication/soft/mucks,I used _./mucks_ in ~/Appilication/soft/mucks and got a tmux session with name mucks1556,the embarrassing suitation was that I couldn't attact the mucks1556 again after detaching the session @wikimatze.

# .mucksrc for mucks project
name: mucks
dir: .
mux: tmux # here is screen for the Second point
[vim]
vim mucks test.sh mucksrc.example
[shell]
[man]
man tmux

I found tmux was running,cloud you give some solutions to fix it?

ps |grep tmux
2150 ttys000    0:00.02 sh -c tmux -S /var/folders/r5/82pn5t7s0nv38ywttt5hzvn80000gn/T//mucks1556 attach-session -t mucks1556; rm -f /var/folders/r5/82pn5t7s0nv38ywttt5hzvn80000gn/T//mucks1556
2153 ttys000    0:00.02 tmux -S /var/folders/r5/82pn5t7s0nv38ywttt5hzvn80000gn/T//mucks1556 attach-session -t mucks1556

Second → The index of the windos in Gnu screen behave differently with mucks or not.

With the .screenrc in ~, the screen -S test command got the result below,and C-b 1 switched window to 1-bash.
screen_outside_mucks

However, with the same .screenrc file , I start a screen session with ./mucks in **~/Appilication/soft/mucks**and the result was something different. The index of the window started from 0, I want to get the index starting from 1,Could you help me?
screen_inside_mucks

[Notice]: Other Important System environment

#>uname -a
Darwin FangHuans-MacBook-Pro.local 14.0.0 Darwin 
Kernel Version 14.0.0: Wed May 28 9:24:32 PDT 2015; 
root:xnu-3247.1.106~1/RELEASE_X86_64 x86_64

#>gawk --v
GNU Awk 4.1.3, API: 1.1
Copyright (C) 1989, 1991-2015 Free Software Foundation.

#>screen -v
Screen version 4.03.01 (GNU) 28-Jun-15

#> cat ~/.screenrc

# .screen config file
startup_message off
vbell off
altscreen on
hardstatus on
hardstatus alwayslastline
backtick 1 86400 86400 whoami
backtick 2 86400 86400 uname -m
hardstatus string "%{= kY}%1`%{+b G}@%{+b Y}%H%{-b G} (%2`) %-=%{G}%100` %{w}|%{-} %{Y}%Y%{-}.%{Y}%m%{-}.%{Y}%d%{-} %D %{Y}%C%{-}:%{Y}%s%{-} %a"
caption always
caption string "%-Lw%{= bw}%50>%n %t%{-}%+Lw%<"
term "screen-256color"
shell /bin/zsh
escape ^Bb
defscrollback 2000
termcapinfo xterm* ti@:te@
bind r source $HOME/.screenrc
bind j focus down
bind k focus up
bind t focus top
bind h focus left
bind b focus bottom
bind s windowlist
bind c screen 1
bind ^c screen 1
bind 0 select 10
screen 1
defscrollback 5000
mousetrack on
altscreen on

Hi @fanghuan, thanks for reporting this. I've two running mucks and ps -aux | grep tmux gives me:

wm~  % ps -aux | grep tmux
wm       17523  0.1  0.0   7748  3488 ?        Ss   18:21   0:00 tmux -S /tmp/blog new-session -d -s blog -n main
wm       18119  0.0  0.0   2276   600 pts/2    S+   18:21   0:00 sh -c tmux -S /tmp/blog attach-session -t blog; rm -f /tmp/blog
wm       18120  0.0  0.0   6852  2024 pts/2    S+   18:21   0:00 tmux -S /tmp/blog attach-session -t blog
wm       19580  0.2  0.0   7824  3476 ?        Ss   18:21   0:00 tmux -S /tmp/javascript new-session -d -s javascript -n text
wm       20059  0.0  0.0   2276   604 pts/16   S+   18:21   0:00 sh -c tmux -S /tmp/javascript attach-session -t javascript; rm -f /tmp/javascript
wm       20060  0.0  0.0   6852  2088 pts/16   S+   18:21   0:00 tmux -S /tmp/javascript attach-session -t javascript
wm       21813  0.0  0.0   6420  2276 pts/22   S+   18:22   0:00 grep tmux

(I modified the script to have names instead of mucks<pid> as session names. So the mucks session are started as sockets. When I detach the javasciptsession I get:

ps -aux | grep tmux
wm       17523  0.0  0.0   7748  3488 ?        Ss   18:21   0:00 tmux -S /tmp/blog new-session -d -s blog -n main
wm       18119  0.0  0.0   2276   600 pts/2    S+   18:21   0:00 sh -c tmux -S /tmp/blog attach-session -t blog; rm -f /tmp/blog
wm       18120  0.0  0.0   6852  2024 pts/2    S+   18:21   0:00 tmux -S /tmp/blog attach-session -t blog
wm       19580  0.0  0.0   7824  3476 ?        Ss   18:21   0:00 tmux -S /tmp/javascript new-session -d -s javascript -n text
wm       26056  0.0  0.0   6420  2312 pts/22   S+   18:24   0:00 grep tmux

And tmux attach-session javascript is not working. I think it has to something with the socket thing in which tmux is started.

Found the solution with the sockets and the attach/detach issue #3:

Replace in the mucks file:

function pre(cmd) {
    if (CONFIG["mux"] == "tmux") {
        return "tmux -S " CONFIG["tmpdir"] "/" id() " " cmd
    } else if (CONFIG["mux"] == "screen") {
        return "screen -S " id() " " cmd
    }
}

with:

function pre(cmd) {
    if (CONFIG["mux"] == "tmux") {
        return "tmux " cmd
    } else if (CONFIG["mux"] == "screen") {
        return "screen -S " id() " " cmd
    }
}

@fanghuan I can't help you either - don't have a Mac.

Thank you 👍 ,Your advice worked for the first problem.

As for the second problem, I tested the same .screenrc file in linux system, the result turned out to be the same with Mac.So I think the proble has lillte relationship with my Mac enrironment.

[linux system environment ]
>uname -a
Linux star 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

>gawk --v
GNU Awk 3.1.5
Copyright (C) 1989, 1991-2005 Free Software Foundation.

>screen -v
Screen version 4.00.03 (FAU) 23-Oct-06

And I found a new problem, the [name]: project_name in .mucksrc file didn't take effect.I tested in Mac and Linux, the session name of tmux(screen) were mucks****, But I don't how to fix it in mucks.

The solution to the second problem can be found under wikimatze@ff5ec31. You can take my fork under https://github.com/wikimatze/mucks to enjoy the lightweight tmux manager.

Thanks, the mucks finally works 👍

Glad I could help you and glad that it works now for you on OSX.

@fanghuan can you close this ticket?

Ok,Thank you again!