Skip to content

Commit 2973b2c

Browse files
committed
Ticket #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 Co-authored-by: Jarkko Sakkinen <jarkko.sakkinen@iki.fi> Closes #4726 Signed-off-by: Johannes Altmanninger <aclopte@gmail.com>
1 parent c727491 commit 2973b2c

File tree

10 files changed

+49
-10
lines changed

10 files changed

+49
-10
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.*
22
!mc-wrapper.*.in
33
mc.csh
4+
mc.fish
45
mc.sh

contrib/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ noinst_DATA = README.xterm
33

44
SCRIPTS_IN = \
55
mc.csh.in \
6+
mc.fish.in \
67
mc.sh.in \
78
mc-wrapper.csh.in \
9+
mc-wrapper.fish.in \
810
mc-wrapper.sh.in
911
SCRIPTS_OUT = \
1012
mc.csh \
13+
mc.fish \
1114
mc.sh \
1215
mc-wrapper.csh \
16+
mc-wrapper.fish \
1317
mc-wrapper.sh
1418

1519
pkglibexec_SCRIPTS = $(SCRIPTS_OUT)

contrib/mc-wrapper.fish.in

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
@bindir@/mc -P "$MC_PWD_FILE" $argv || true
11+
12+
if test -r "$MC_PWD_FILE"
13+
set --local MC_PWD (cat $MC_PWD_FILE)
14+
if test -n $MC_PWD && test $MC_PWD != $PWD && test -d $MC_PWD
15+
cd $MC_PWD || true
16+
end
17+
end
18+
19+
rm -f $MC_PWD_FILE

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),r
8282
.B %pkglibexecdir%/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

doc/man/ru/mc.1.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ Commander.
9090
.IP
9191
Для того чтобы эта функция была определена, используйте файл
9292
.B %pkglibexecdir%/mc.sh
93-
для оболочек bash и zsh, а для оболочки tcsh соответственно файл
93+
для оболочек bash и zsh, или для оболочки tcsh файл
9494
.B %pkglibexecdir%/mc.csh
95+
а для оболочки fish соответственно файл
96+
.B %pkglibexecdir%/mc.fish
9597
.TP
9698
.I \-s, \-\-slow
9799
Включает медленный режим терминала, в котором программа выводит меньше

doc/man/sr/mc.1.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ termcap/terminfo. Корисно је само на ХП\-овим термин
6464
.B %pkglibexecdir%/mc.sh
6565
(за кориснике љуски bash и zsh) или
6666
.B %pkglibexecdir%/mc.csh
67-
(за кориснике љуске tcsh), тим редом, да бисте задали
67+
(за кориснике љуске tcsh) или
68+
.B %pkglibexecdir%/mc.fish
69+
(за кориснике љуске fish), тим редом, да бисте задали
6870
.B mc
6971
као надимак за одговарајући спис љуске.
7072
.TP

0 commit comments

Comments
 (0)