Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cd - intercept interferes with cd doskey alias #549

Closed
eggbean opened this issue Jan 16, 2024 · 6 comments
Closed

cd - intercept interferes with cd doskey alias #549

eggbean opened this issue Jan 16, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@eggbean
Copy link

eggbean commented Jan 16, 2024

I have a doskey macro which aliases cd to a script for CD Deluxe (which I've been using for around 15 years) and does some other stuff including setting a %OLDPWD% variable which I find useful. I've never been able to get it to fully work, but I realised that it does actually work when I have clink turned off.

I would like to turn off this cd - intercept, but I cannot see any option for doing this. Is there a way I can achieve this?

@eggbean eggbean changed the title How can I disable cd - intercept - commit 81e0e88 ? How can I disable cd - intercept (commit 81e0e88) ? Jan 16, 2024
@chrisant996
Copy link
Owner

chrisant996 commented Jan 16, 2024

This sounded related to something I saw with cd-deluxe in the past. I tracked down my memory to shunsambongi/clink-zoxide#5 which was opened by you, and we had a conversation there.

There isn't a way to turn off directory intercept.

Can you share what isn't working? With some information about your macros and scripts and what isn't working, it would be possible to fix the problems that they're experiencing.

@chrisant996 chrisant996 added needs more information The issue needs clarifying information question Question about something labels Jan 16, 2024
@chrisant996
Copy link
Owner

Specifically what "doesn't work"?

The only thing I can think of is that you want cd - to be handled by your cd alias, so that cdd - is invoked and the "go to previous directory" is handled by CD-Deluxe instead of by Clink, so that the side effects happen such as setting %OLDPWD%.

I think the issue is that in addition to checking for "cd" or "chdir", Clink should also first confirm that there isn't a corresponding doskey macro.

Can you share what problem(s) you've encountered?

@eggbean
Copy link
Author

eggbean commented Jan 16, 2024

Sorry, I had to commit some changes before replying.

This is my modified version of the cdd.cmd script which is aliased to cd (original is here):

@echo off
set dest=%*
if '%dest%'=='' goto :cdd
if qq%dest:~0,1%%dest:~-1%qq == qq""qq set dest=%dest:~1,-1%
if '%dest:~0,1%' == '~' set dest=%USERPROFILE%%dest:~1%
set dest="%dest%"
set OLDPWD="%CD%"
:cdd
set pushd_tmp=%TEMP%\pushd.tmp
set cdd_tmp_cmd=%TEMP%\cdd.tmp.cmd
pushd > %pushd_tmp%
%~dps0_cdd.exe %dest% < %pushd_tmp% > %cdd_tmp_cmd%
set dest=
%cdd_tmp_cmd%

The set OLDPWD="%CD%" works in every case apart from when the original command is cd -, where the script is bypassed altogether. (This doesn't otherwise disrupt the working of CD Deluxe though.)

@chrisant996
Copy link
Owner

Ok thanks. It's the case I guessed. Clink should check whether there's an alias for cd that expands to run something other than cd, and if so then it shouldn't intercept at all.

Also, it should check for & or | after the cd blah_whatever command, and if present then it also shouldn't intercept.

@chrisant996 chrisant996 added bug Something isn't working and removed needs more information The issue needs clarifying information question Question about something labels Jan 17, 2024
@chrisant996 chrisant996 changed the title How can I disable cd - intercept (commit 81e0e88) ? cd - intercept interferes with cd doskey alias Jan 17, 2024
@chrisant996
Copy link
Owner

I updated the title to describe the issue.

@eggbean
Copy link
Author

eggbean commented Jan 19, 2024

Excellent, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants