1

I would like to define the following keys in Cmder:

Alt+Up -> move to parent directory (Ctrl+Alt+U)

Alt+Left -> move to previous directory (the one I was in before the last cd)

Alt+Right -> move to next directory


Any help ?

Tomasz Jakub Rup
  • 632
  • 5
  • 14
kofifus
  • 297
  • 1
  • 3
  • 14
  • Which version of Cmder are you using? I haven't found in my version any directory-movement hotkeys. – harrymc Jun 22 '17 at 05:37
  • latest version. I don't understand what you're asking, if they were such hotkeys defined already I wouldn't be asking this ... – kofifus Jun 25 '17 at 01:30
  • Please post a link to your version. – harrymc Jun 25 '17 at 06:11
  • the 'download full' at cmder.net – kofifus Jun 25 '17 at 06:25
  • That's the one I'm using and I cannot find anything like that in Settings / Keys & Macro, and the combo ctrl+alt+u only produces an accented character. The only solution I can think of is to use [AutoHotkey](https://autohotkey.com/) to automate the [pushd and popd commands](https://en.wikipedia.org/wiki/Pushd_and_popd). If this is an acceptable solution, I can post it as an answer. – harrymc Jun 25 '17 at 07:56
  • 1
    ctrl+alt+u switch to the directory above, if it doesn't work for you maybe clink did not install properly. The hotkeys are defined in vendors\clink\clink_inputrc_base but I don't know how to define alt+up there. Autohotkeys is not acceptable thx. – kofifus Jun 25 '17 at 09:01

1 Answers1

2

As you said AutoHotKeys is not acceptable, it is difficult to move to previous and next directory, but it can be done. I have added one way to achieve it, but moving up the directory is pretty simple.

  • Press Windows+Alt+P for settings and goto the Keys and Macros Section.
  • Select the Macros from the dropdown.
  • Select an empty Macro and Assign Alt+Up
  • Next in the GUI Macro, set the value as print("cd ..\n"). This will set the go back to parent directory. The \n in the print statement mimics an Enter keypress.

One way you can achieve to go back to the previous directory is by setting pushd as an alias to cd. For example, if you are using , you can set the alias like this: remove-item alias:\cd ; set-alias "cd" "pushd"

Now, you can set the Alt+Left key to print("popd\n") to go back to the previous location.

mrsauravsahu
  • 240
  • 1
  • 9
  • "Select an empty Macro and Assign Alt+Up" .. I am unable to do this, I can only capture Up but not Alt+Up .. did it work for you ? I don't want to override the default "Up" behaviour of history scrolling thx – kofifus Jun 25 '17 at 22:17
  • There are drop downs above the gui macro entry field, just select alt from there. – mrsauravsahu Jun 26 '17 at 02:44