start Cygwin from Total Commander
Moderators: white, Hacker, petermad, Stefan2
start Cygwin from Total Commander
Hi guys,
Currently I start Cygwin from TC by right click, Cygwin can be started and "cd" the current directory.
Right click integration is done by add this key to Windows registry:
c:\cygwin\bin\bash.exe --login -i -c 'cd "`cygpath "$*"`";bash' bash %L
Can I set a hot-key in TC for to do this?
Thanks in advance!
Darylz
Currently I start Cygwin from TC by right click, Cygwin can be started and "cd" the current directory.
Right click integration is done by add this key to Windows registry:
c:\cygwin\bin\bash.exe --login -i -c 'cd "`cygpath "$*"`";bash' bash %L
Can I set a hot-key in TC for to do this?
Thanks in advance!
Darylz
Hi, I used %P instead of %L, and it works, even with paths containing spaces.darylz wrote: For Explorer right click integration, "%L" is used to represent the current directory, but in TC, how to get this info transfer as an argument?
BTW you can also change the user menu in Total Commander itself.
but I got an error:
Code: Select all
bash: cd: %P: No such file or directory
When you start Cygwin bash, it starts in your Cygwin home directory. Puth this in ~/.profile :
cd "$OLDPWD"
to make it jump back to the starting directory.
Now you must start Cygwin from the current directory in Windows :
[User]
Menu1=Cygwin shell
Cmd1=c:\cygwin\bin\bash.exe
Param1=--login -i
Path1=%P
cd "$OLDPWD"
to make it jump back to the starting directory.
Now you must start Cygwin from the current directory in Windows :
[User]
Menu1=Cygwin shell
Cmd1=c:\cygwin\bin\bash.exe
Param1=--login -i
Path1=%P
Best regards
Freddy Vejen
Freddy Vejen
Strange, my start menu entry looks like this, and is working fine.darylz wrote:but I got an error:
Code: Select all
bash: cd: %P: No such file or directory
Image: http://img151.imageshack.us/img151/4386/sshot2ou2.png
Thanks!
This post helped a lot. For any noobs like myself, here is what I have working.
The text file that holds custom commands should be located somewhere like this:
c:\Documents and Settings\%username%\Application Data\GHISLER\usercmd.ini
It might also be in your c:\totalcmd folder, depending on how it is installed. If you don't have one, just create it.
I have the following two entries in my file.
To use them,
Good luck!
The text file that holds custom commands should be located somewhere like this:
c:\Documents and Settings\%username%\Application Data\GHISLER\usercmd.ini
It might also be in your c:\totalcmd folder, depending on how it is installed. If you don't have one, just create it.
I have the following two entries in my file.
The first one opens a BASH shell at the directory that has focus. The second one starts tailing the file you have selected.[em_cygwin_shell]
button=
cmd=c:\cygwin\bin\bash.exe --login -i -c 'cd "`cygpath "$*"`";bash' bash
param=%P
[em_cygwin_tail]
button=
cmd=c:\cygwin\bin\bash.exe --login -i -c 'tail -f "`cygpath "$*"`";bash' bash
param=%P%N
To use them,
- right click on the button bar and select Change.
(You can also select it from the Configuration menu.) - add a new button
- click the magnifying glass button to the right of the Command text
- select usercmd.ini at the bottom of the category list
- and choose the command you want to use.
Good luck!
I would recommend PuTTYcyg.
in "cygwin\etc\profile" comment out 'cd "$HOME"':
and create a button in TC to launch patched version of putty.
It will always open working dir.
CMD shell is a poor replacement for PuTTYCyg... That is the set-up I use
in "cygwin\etc\profile" comment out 'cd "$HOME"':
Code: Select all
# Make sure we start in home
#cd "$HOME"
Code: Select all
Command: PuttyCygwin\puttycyg-20101029\putty.exe
Params : -cygterm -
CMD shell is a poor replacement for PuTTYCyg... That is the set-up I use
Ambiguity succeeds where honesty dares not venture.
Interesting! I wish I could use that, but I don't want to edit the profile (else it won't get updated).
Another problem I have is that Cygwin now defaults to put my home directory under Docs&Settings\... instead of the Cygwin\home\... folder. I hate that, so I set a Windows environment variable HOME to be c:\cygwin\home\%username%.
But PuTTYcyg does not expand the %username% variable and creates an ugly folder.
I wish I knew how to make Cygwin use the old style home path without having to hack it like that, but I don't.
Another problem I have is that Cygwin now defaults to put my home directory under Docs&Settings\... instead of the Cygwin\home\... folder. I hate that, so I set a Windows environment variable HOME to be c:\cygwin\home\%username%.
But PuTTYcyg does not expand the %username% variable and creates an ugly folder.
I wish I knew how to make Cygwin use the old style home path without having to hack it like that, but I don't.
I just looked at the new Cygwin installation, one does no longer need to delete "cd $HOME" or do 'cd "$OLDPWD"' as fredvej suggested (nice trick though), you can do:
As a sidenote, I miss setting ENV directly from TC button
2Naruki
I have never had the kind of set-up where Cygwin HOME is set to any other value than the one I wished What pops to mind is that you may try calling "mkpasswd.exe -l" to check whether your /etc/passwd file OK and "mkgroup.exe -l" for /etc/group.
Code: Select all
cmd /C set CHERE_INVOKING=true && start <path>\putty.exe -cygterm -
2Naruki
I have never had the kind of set-up where Cygwin HOME is set to any other value than the one I wished What pops to mind is that you may try calling "mkpasswd.exe -l" to check whether your /etc/passwd file OK and "mkgroup.exe -l" for /etc/group.
Ambiguity succeeds where honesty dares not venture.
Fairly awesome!frenky wrote:2NarukiCode: Select all
cmd /C set CHERE_INVOKING=true && start <path>\putty.exe -cygterm -
I have never had the kind of set-up where Cygwin HOME is set to any other value than the one I wished What pops to mind is that you may try calling "mkpasswd.exe -l" to check whether your /etc/passwd file OK and "mkgroup.exe -l" for /etc/group.
I tried using those programs to fix my problem, but I'm still too noobish to understand what to do. I don't know how my home directory got mis-set to begin with, but nothing I tried could fix it.
So I blew away the c:\Cygwin folder and re-installed. That fixed it.
Now your command works quite nicely for me. Thanks!
Cygwin shell and Cygwin emacs and etc
Install the chere package in cygwin (for explorer integration install with "chere -i").
Add a button:
For cygwin native emacs (no X server needed), it can't deal with backslashes, so run file name through a batch file converter. Set this up using:
Where that batch file is (change RUN to where cygwin is installed):
This depends on editing /etc/fstab to include:
So that instead of /cygdrive/c you simply use /c
After fixing /etc/fstab, to use your C:\Users\YOU directory as home instead of /home/YOU, edit /etc/passwd and where your name is at the end use:
For emacs I think I needed Control Panel | System | env vars | then:
Cygwin native emacs icon:
Cygwin emacs startup using above shortcut now needs path to cygwin. In ~/.emacs:
Launch TotalCommander from Cygwin emacs in dired by typing capital W. Edit ~/.emacs:
Add a button:
Code: Select all
command: C:\Apps\Cyg\bin\mintty.exe
parameters: -t "Cygwin" -e /bin/xhere /bin/bash.exe '%P'
icon file: C:\Apps\Cyg\bin\mintty.exe
Code: Select all
Configuration | Options | Edit/View | Editor for F4 | Editor: C:\Apps\bin\LaunchEmacs.bat
Code: Select all
@echo off
set RUN=C:\apps\cyg\bin\run.exe
:: Convert C:\Apps\bin into /c/Apps/bin so Cygwin emacs can grok
set file=%1
set file=%file:\=/%
set file=%file:C:=/c%
%RUN% /bin/emacs "%file%"
Code: Select all
C: /c ntfs binary,user 1 1
After fixing /etc/fstab, to use your C:\Users\YOU directory as home instead of /home/YOU, edit /etc/passwd and where your name is at the end use:
Code: Select all
YOU:...stuff...:/c/Users/YOU:/bin/bash
Code: Select all
HOME C:\Users\YOU
HOMEDRIVE C:\
HOMEPATH \Users\YOU
Code: Select all
Program C:\Apps\Cyg\bin\run.exe emacs
Icon C:\Apps\Cyg\bin\emacs-w32.exe
Code: Select all
(setenv "PATH" (concat "/bin:/usr/bin:/usr/local/bin:" (getenv "PATH")))
(nconc exec-path '("/bin" "/usr/bin" "/usr/local/bin"))
Code: Select all
(add-hook 'dired-mode-hook
'(lambda ()
(progn
(local-set-key "W" 'dired-run-windows-commander))))
(defun dired-run-windows-commander ()
"Run Windows Commander on marked file in dired mode."
(interactive)
(progn
(message '"Executing...")
(let ((file (dired-get-filename)))
(setq file (replace-regexp-in-string "^/c\\(.*\\)$" "\"C:\\1\"" file))
(setq file (replace-regexp-in-string "/" "\\\\" file))
(w32-shell-execute nil "/c/Apps/totalcmd/TOTALCMD64.EXE" file)
)
)
)
Re: Thanks!
Work fine !! Thanks !!
Naruki wrote: ↑2011-02-23, 16:15 UTC This post helped a lot. For any noobs like myself, here is what I have working.
The text file that holds custom commands should be located somewhere like this:
c:\Documents and Settings\%username%\Application Data\GHISLER\usercmd.ini
It might also be in your c:\totalcmd folder, depending on how it is installed. If you don't have one, just create it.
I have the following two entries in my file.
The first one opens a BASH shell at the directory that has focus. The second one starts tailing the file you have selected.[em_cygwin_shell]
button=
cmd=c:\cygwin\bin\bash.exe --login -i -c 'cd "`cygpath "$*"`";bash' bash
param=%P
[em_cygwin_tail]
button=
cmd=c:\cygwin\bin\bash.exe --login -i -c 'tail -f "`cygpath "$*"`";bash' bash
param=%P%N
To use them,Technically, you can just enter the name of the command in the Command text field, but this way you know how to find other commands if you want.
- right click on the button bar and select Change.
(You can also select it from the Configuration menu.)- add a new button
- click the magnifying glass button to the right of the Command text
- select usercmd.ini at the bottom of the category list
- and choose the command you want to use.
Good luck!