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

Clink_inputrc not being processed if it the clink_inputrc is a link (created via mklink) #342

Closed
idvorkin opened this issue Aug 25, 2015 · 14 comments

Comments

@idvorkin
Copy link

I've install with chocolaty. I tried a bunch of locations and no luck. How can I debug if I have this in the wrong location vs syntax error? It'd be great if I could look in the log file to see what file location was searched for clink_inputrc. FYI - I'm clink version:

C:\Users\Igor>clink
Clink v0.4.3 [git:258fc3] Copyright (c) 2014 Martin Ridgers
http://mridgers.github.io/clink

@idvorkin idvorkin changed the title Clink_inputrc being ignored. Where is clink_inputrc read from given a chocolaty install? Clink_inputrc setting not working. I supect the problem is install location, how to debug? Aug 25, 2015
@uahim
Copy link

uahim commented Aug 25, 2015

clink set should give you the settings file path

e.g. on my system the file name is settings, not clink_inputrc (C:\Program Files\clink\0.4.4\profile\settings)

@mridgers
Copy link
Owner

Your clink_inputrc file should be alongside Clink's settings file. The clink_inputrc is included from the last line of Clink's internal clink_inputrc_base file. Readline expands the ~ to the same path as Clink's settings file which can be found with clink set as @uahim mentioned.

The settings file is where Clink persists its own settings and the clink_inputrc is for modifying Readline's key bindings and defining macros.

It is worth noting that this path can unfortunately change depending on how Clink is start. It has been reported in #298.

@idvorkin
Copy link
Author

Perfect. I now think I'm using the correct path. Now, my setting aren't getting picked up :) I'm trying to set VI mode, but when I create new terminals, I'm not in VI mode until I type C-A-J. How do I debug?

Here are my settings:

C:\Users\Igor\AppData\Local\clink>clink set
Available options:
<SNIP> 
Settings path: C:\Users\Igor\AppData\Local.\clink/settings

C:\Users\Igor\AppData\Local\clink>type clink_inputrc
# Swap edit modes using C-A-J
set editing-mode vi
set keymap vi-command

Also, out of curiosity why don't you use %USERPROFILE%/clink_inputrc? (Or some set of paths with that being one of the choices)

@mridgers
Copy link
Owner

Also, out of curiosity why don't you use %USERPROFILE%/clink_inputrc?

Clink used to do this but this behaviour did not suit people who run Clink in "portable" mode (from a USB stick for example). So a hybrid was introduced where %LOCALAPPDATA%* is used when Clink's installed. It's not perfect though, hence #298 was raised.

* %APPDATA% or %LOCALAPPDATA% are better choices for modern versions of Windows if you want to be a good Windows citizen.

@idvorkin
Copy link
Author

So it seems my cink_inputrc is in the right spot. Any idea why set editing-mode vi is being ignored? How can I debug?

@mridgers
Copy link
Owner

I just double checked this is behaving as I expected, which it is. Here's what I did;

  1. Create a new clink_inputrc file where Clink expects it (which is ~/clink_inputrc); type c:\ echo 2>~\clink_inputrc (using Readline's Alt-~ to expand the ~).
  2. Edit the file; notepad ~\clink_inputrc (with Alt-~ expansion again), adding the line set editing-mode vi.
  3. Tell Readline to reload its init file with the Ctrl-x Ctrl-r key sequence (or restart Clink).
  4. Clink's now in vi editing mode.

Debugging is pretty tricky if I'm honest as Readline doesn't give any feedback. You can easily confirm the clink_inputrc's in the correct place by adding a simple key sequence macro;

C-f: "foobar"

If all is working as expected pressing Ctrl-f will insert the text foobar (note that this is bound to the emacs keymap so you might want to skip setting the editing mode for the sake of testing).

@idvorkin
Copy link
Author

Using the Foobar alias is a great way to debug

I found the issue, clink is ignoring the settings file if it's a symlink (created via mklink). Using a regular file, it works - WOOT!

Unrelated to this issue, how does Alt-~ expansion work? On my box pressing Alt-~ does nothing.

@idvorkin idvorkin changed the title Clink_inputrc setting not working. I supect the problem is install location, how to debug? Clink_inputrc setting not being processed if it the clink_inputrc is a link (created via mklink) Sep 23, 2015
@idvorkin idvorkin changed the title Clink_inputrc setting not being processed if it the clink_inputrc is a link (created via mklink) Clink_inputrc not being processed if it the clink_inputrc is a link (created via mklink) Sep 23, 2015
@mridgers
Copy link
Owner

Alt-~ expands a ~ if the cursor is on a path that begins with ~ or '~`. For example;

  Works; C:\>cd ~
  Works; C:\>cd ~\foo\bar
  Works; C:\>cd ~/foo/bar
Invalid; C:\>cd ~asdf
Invalid; C:\>cd asdf~asdf

I don't know what the impact is of using a keyboard layout other than US or UK. If I switch to a Swedish layout then Windows buffers the ~ until the next key press which doesn't work well for Alt-~. If that applies to you you may want to bind different keys in your inputrc.

Apologies for the late reply.

@idvorkin
Copy link
Author

An update if anyone skims this thread

Since Issue: #258 has been fixed, _inputrc should be placed in the %USERPROFILE% directory.

Links are still broken though.

@khaoos-abominable
Copy link

I had the same issue. It seems that clink doesn't follow symlinks. But hardlinks work though and it fits me.

rivy added a commit to rivy/clink that referenced this issue Jul 9, 2017
rivy added a commit to rivy/clink that referenced this issue Jul 9, 2017
rivy added a commit to rivy/clink that referenced this issue Jul 9, 2017
@rivy
Copy link

rivy commented Jul 9, 2017

@idvorkin & @khaoos-abominable ,

The symlink issue is caused by a bug in the readline config file parsing code (specifically, _rl_read_file()).

PR#462 should fix it.

Stanzilla pushed a commit to Stanzilla/clink that referenced this issue Aug 14, 2017
Stanzilla pushed a commit to Stanzilla/clink that referenced this issue Dec 21, 2017
rivy added a commit to rivy/clink that referenced this issue Nov 3, 2018
@chrisant996
Copy link

Readline 8.0 fixed this (in exactly the same way), and the chrisant996/clink fork was updated to use Readline 8.0, so moving forward this has been addressed.

@rivy
Copy link

rivy commented Oct 7, 2020

It's already been fixed in other forks since July of 2017.

@chrisant996
Copy link

chrisant996 commented Oct 8, 2020

It's already been fixed in other forks since July of 2017.

But not in the mridgers repo, which is the natural source to fork for producing a new resurrected clink.

I'm making notes in issues to keep track of what's addressed in this new fork. And so that if people know of specific fixes in various forks then they can send me commits or pull requests to incorporate them into the chrisant996 fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants