Skip to content

Commit ee2dec5

Browse files
zyvjarkkojs
andcommitted
Ticket MidnightCommander#4726: add mc wrapper for fish shell
fish shell occasionally gets bug reports from mc users, so there are definitely some mc+fish users, but none of them has noticed the lack of "/usr/libexec/mc/mc-wrapper.fish". That file is supposed to define an alias that behaves like mc except that, after mc exits, it will change fish's directory to the one last used by mc. Users need to source this manually; if this is the behavior that most people expect, we should make it the default (for example by shipping this function with fish). For now, add it to mc, which shouldn't break anyone even if fish decides to add this as well. Note that fish does not do word splitting, so variable expansions usually don't need to be quoted. Tested as follows: $ make install $ type mc mc is /home/johannes/.local/bin/mc $ source /home/johannes/.local/libexec/mc/mc.fish $ type mc mc is a function with definition # Defined in /home/johannes/.local/libexec/mc/mc.fish @ line 1 function mc --description 'Visual shell for Unix-like systems - fish wrapper' source /home/johannes/.local/libexec/mc/mc-wrapper.fish $argv end mc # navigate somewhere, press F10 to exit Closes MidnightCommander#4726. Co-authored-by: Jarkko Sakkinen <jarkko.sakkinen@iki.fi> Signed-off-by: Johannes Altmanninger <aclopte@gmail.com> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
1 parent cd1eeed commit ee2dec5

File tree

12 files changed

+56
-12
lines changed

12 files changed

+56
-12
lines changed

contrib/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mc-wrapper.csh
22
mc-wrapper.sh
33
mc.csh
4+
mc.fish
45
mc.sh

contrib/Makefile.am

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
noinst_DATA = README.xterm
33

4-
SCRIPTS_IN = mc.csh.in mc.sh.in mc-wrapper.csh.in mc-wrapper.sh.in
5-
SCRIPTS_OUT = mc.csh mc.sh mc-wrapper.csh mc-wrapper.sh
4+
SCRIPTS_IN = mc.csh.in mc-wrapper.fish.in mc.sh.in mc-wrapper.csh.in mc-wrapper.sh.in
5+
SCRIPTS_OUT = mc.csh mc.sh mc-wrapper.csh mc-wrapper.fish mc-wrapper.sh
66

77
pkglibexec_SCRIPTS = $(SCRIPTS_OUT)
88

@@ -20,12 +20,18 @@ EXTRA_DIST = \
2020
mc.csh: $(top_builddir)/config.status $(srcdir)/mc.csh.in
2121
$(SED) "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.csh.in > mc.csh
2222

23+
mc.fish: $(top_builddir)/config.status $(srcdir)/mc.fish.in
24+
$(SED) "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.fish.in > mc.fish
25+
2326
mc.sh: $(top_builddir)/config.status $(srcdir)/mc.sh.in
2427
$(SED) "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.sh.in > mc.sh
2528

2629
mc-wrapper.csh: $(top_builddir)/config.status $(srcdir)/mc-wrapper.csh.in
2730
$(SED) "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.csh.in > mc-wrapper.csh
2831

32+
mc-wrapper.fish: $(top_builddir)/config.status $(srcdir)/mc-wrapper.fish.in
33+
$(SED) "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.fish.in > mc-wrapper.fish
34+
2935
mc-wrapper.sh: $(top_builddir)/config.status $(srcdir)/mc-wrapper.sh.in
3036
$(SED) "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.sh.in > mc-wrapper.sh
3137

contrib/mc-wrapper.csh.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ else
66
setenv MC_PWD_FILE "`mktemp '/tmp/mc.pwd.XXXXXX'`"
77
endif
88

9+
# Propagate mc exit code outside the wrapper
910
@bindir@/mc -P "$MC_PWD_FILE" $*
1011

1112
if (-r "$MC_PWD_FILE") then

contrib/mc-wrapper.fish.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
set --local MC_PWD_FILE
2+
if set -q MC_TMPDIR
3+
set MC_PWD_FILE (mktemp $MC_TMPDIR/mc.pwd.XXXXXX)
4+
else if set -q TMPDIR
5+
set MC_PWD_FILE (mktemp $TMPDIR/mc.pwd.XXXXXX)
6+
else
7+
set MC_PWD_FILE (mktemp /tmp/mc.pwd.XXXXXX)
8+
end
9+
10+
# Propagate mc exit code outside the wrapper
11+
@bindir@/mc -P "$MC_PWD_FILE" $argv
12+
13+
if test -r "$MC_PWD_FILE"
14+
set --local MC_PWD (cat $MC_PWD_FILE)
15+
if test -n $MC_PWD && test $MC_PWD != $PWD && test -d $MC_PWD
16+
cd $MC_PWD || true
17+
end
18+
end
19+
20+
rm -f $MC_PWD_FILE

contrib/mc-wrapper.sh.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ else
66
MC_PWD_FILE="`mktemp "/tmp/mc.pwd.XXXXXX"`"
77
fi
88

9+
# Propagate mc exit code outside the wrapper
910
@bindir@/mc -P "$MC_PWD_FILE" "$@"
1011

1112
if test -r "$MC_PWD_FILE"; then

contrib/mc.fish.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function mc --description 'Visual shell for Unix-like systems - fish wrapper'
2+
source @pkglibexecdir@/mc-wrapper.fish $argv
3+
end

doc/man/es/mc.1.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ usada directamente, sino desde un guión de shell adecuado, para dejar
9292
como directorio activo el directorio que estaba en uso dentro de
9393
Midnight Commander. Consúltese en los archivos
9494
.B %pkglibexecdir%/mc.sh
95-
(usuarios de bash y zsh) y
95+
(usuarios de bash y zsh),
9696
.B %pkglibexecdir%/mc.csh
97-
(usuarios de tcsh) la manera de definir
97+
(usuarios de tcsh) y
98+
.B %pkglibexecdir%/mc.fish
99+
(usuarios de fish) la manera de definir
98100
.B mc
99101
como un alias para el correspondiente guión de shell.
100102
.TP

doc/man/hu/mc.1.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ helyett a Midnight Commander által utoljára meglátogatott könyvtárra való
6161
Fjerdingstad\-nek és Sergey\-nek közreműködésükért). Kérlek, ne csinálj
6262
szó szerinti másolatot a funkció beállításairól. A fájlok forrása a
6363
.I %pkglibexecdir%/mc.sh
64-
(bash és zsh felhasználóknak), illetőleg a
64+
(bash és zsh felhasználóknak),
6565
.I %pkglibexecdir%/mc.csh
66-
(tcsh felhasználóknak) fájl. Ilyenkor, amikor a funkció beállításokat
66+
(tcsh felhasználóknak) illetőleg a
67+
.I %pkglibexecdir%/mc.fish
68+
(fish felhasználóknak) fájl. Ilyenkor, amikor a funkció beállításokat
6769
változtatod, a profil értékeket nem szükséges megváltoztatnod, csak
6870
arról gondoskodj, hogy az MC\-t ne fordítsd eltérő beállításokkal.
6971
.PP

doc/man/it/mc.1.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ utilizzata da una speciale funzione shell che imposti automaticamente
8282
l'ultima directory corrente della shell come l'ultima directory in cui
8383
stava il Midnight Commander. Prelevate i file
8484
.B %pkglibexecdir%/mc.sh
85-
(utenti bash e zsh) o rispettivamente
85+
(utenti bash e zsh),
8686
.B %pkglibexecdir%/mc.csh
87-
(utenti tcsh) per definire
87+
(utenti tcsh) o rispettivamente
88+
.B %pkglibexecdir%/mc.fish
89+
(utenti fish) per definire
8890
.B mc
8991
come un alias allo script di shell appropriato.
9092
.TP

doc/man/mc.1.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ not meant to be used directly. Instead, it's used from a special shell
7878
script that automatically changes the current directory of the shell to
7979
the last directory Midnight Commander was in. Source the file
8080
.B %pkglibexecdir%/mc.sh
81-
(bash and zsh users) or
81+
(bash and zsh users), or
8282
.B %libexecdir%/mc.csh
83-
(tcsh users) respectively to define
83+
(tcsh users) or
84+
.B %pkglibexecdir%/mc.fish
85+
(fish users) respectively to define
8486
.B mc
8587
as an alias to the appropriate shell script.
8688
.TP

0 commit comments

Comments
 (0)