Add trailing slash in tcsh completion of directory symbolic links - autocomplete

Assume I have a folder ~/Documents
Now when I type /Doc and press tab key, my tcsh would complete the line to /Documents
What I would like to achieve, is to get /Documents/
I found most of the discussions on the Internet is about bash. But here I'm using tcsh. I know this is doable as my previous setup works like this in tcsh.

This is how tcsh should behave by default; but it's controlled with the addsuffix setting; from tcsh(1):
addsuffix (+)
If set, filename completion adds `/' to the end of directories
and a space to the end of normal files when they are matched
exactly. Set by default.

Related

How do you disable fish shell's guessing autocompletion feature?

In bash, if you type something like:
ls /etc/abc
and hit <tab>, it will beep, and do nothing, basically letting you know that it couldn't figure out how to complete it. In the case of that specific command, a file starting with /etc/abc didn't exist.
In fish, it will use some sophisticated algorithm to figure out what it thinks you may have meant, and can change what you typed completely, possible changing your ls /etc/abc to ls /etc/fstab, because at some point in the past, you may have typed ls /etc/fstab.
I'm sure it's not that arbitrary, but the fact is, it removed my /etc/abc arg, and replaced it with what it thought I meant. Sometimes, I made one mistake in one character, and instead of going back and fixing my mistake like I would in bash, hitting <tab> replaced the entire thing I wrote, forcing me to rewrite the entire arg.
I can see how some people might like this feature, but for me, it's insanely annoying. Maybe I'm just used to bash.
Is there a way to have fish turns this off, so it never replaces what I wrote? If I wrote /etc/abc, hit <tab>, and it can't figure out a completion that starts with that, leave it alone. Don't replace it with its best guess.
I don't even know what the feature is called. Does it even have a name, or is it just a nameless part of the autocompletion of fish?
Update:
A real example I just ran into.
I have a file in the current directory named lib.py. I type git difftool li and hit <tab>. It replaces what I wrote with git difftool templates/nxt_connect/dish_controls.html, immediately making me want to stab somebody as I have to delete the super long string it helpfully filled in for me, and try again. What's worse is that I assume I typed something in wrong, so I'll try exactly the same thing, and end up with exactly the same result, only to realize fish doesn't have a completion file built-in for git difftool, which is why it doesn't even check my current directory for files.
and can change what you typed completely, possible changing your ls /etc/abc to ls /etc/fstab,
Fish won't change /etc/abc to /etc/fstab
What it will do is fuzzy-match your command, so e.g. /etc/ft will match /etc/fstab, but that's only because both "f" and "t" are in "fstab" in that order, and only if it was the only possible match.
This won't happen with /etc/abc, because that doesn't match /etc/fstab.
because at some point in the past, you may have typed ls /etc/fstab.
It does not take history into account in this case. It really only uses history for the autosuggestion - the greyed-out continuation of what you typed, but that only does prefix matching.
Is there a way to have fish turns this off, so it never replaces what I wrote?
Fish provides no option to change this behavior.
The next fish release (version 3.2) will offer an "undo" function (bound to ctrl+z by default) so you can undo any match by pressing that.
is it just a nameless part of the autocompletion of fish?
fuzzy matching.

Trim Trailing Whitespace from ALL files in workspace

I know about the Trim Trailing Whitespace command in the pallette, and I know I can run this on save.
Is there a way to trim trailing whitespace on ALL files in a workspace (either with some command combo, or a way to run "save" on every file)
I have seen other answers on how to trim trailing whitespaces using Unix tools, but I would rather use the built in tool from VSCode specifically. (I would accept an answer that shows how to do this in another GUI text editor like Sublime Text also).
I would prefer not to have answers that use Terminal or other Regex matching--I would prefer to use the exact algorithm that is used by GUI tools already, since I trust that they will do the thing I expect. I will be running this on potentially thousands of files, so mistakes could easily go through even after audit.
I am basically trying not to open every file and ⌘+S it manually.
I am on macOS if that changes anything (but I doubt it matters)
This can be done using the search-and-replace function (keyboard shortcuts given below are for Linux, likely similar to what exists on a Mac):
Ctrl-Shift-H (open the search-and-replace side panel)
Type +$ in the Search field (that is a space, a plus and a dollar, meaning one or more spaces anchored at the end of the line)
Click the .* regular expression button next to the Search field
Leave the Replace field empty
Press Ctrl-Alt-Enter (or press the Replace All button next to the Replace field)
Click Replace (or Alt-R) in the confirmation pop up which also tells you the number of occurrences and files that will be touched
Be careful, as a wrong search or replace argument can mess up many files all at once!

Navigating within directories with name having spaces

I am using Windows 7, EmacsW32 and Emacs23
I am trying to navigate inside a directory whose name has spaces with within Emacs. So, I try to navigate to it in Dired mode by:
C-x d
And then navigate to the directory name with spaces (e.g. My Documents) and the suggestion and auto-complete feature (upon pressing TAB) does not work. How can I navigate to folders and files within such directories without removing spaces?
UPDATE: I tried few other paths with spaces in some directories, and it works. i don't know in which situations it works and fails. It works for Program Files but fails for My Documents.
I am taking a shot in the dark, but unix's case escapes are "\ " and I believe windows does the same.
This may not solve your problem directly.
As you described, I think you may not use ido-mode now. The default tab complete in emacs is weak. Try ido-mode, it is fantastic.
I can't replicate this particular issue, however:
To enter a literal space, type C-qSPC
C-q runs the command quoted-insert which ensures that the next character typed is inserted into the current buffer, which can be useful when the key in question is bound to some function.
The problem is not with folders with spaces in it. The problem is only with My Documents, My Videos and similarly named folders.
When I go in the windows file browser and check the path of the folder My Documents, it appears as C:/..../Documents/...
So, I tried to open Documents instead of My Documents in Emacs and it works. Now I am able to access my files under Documents.

How to use wildcards to auto-complete on remote server in zsh?

One of my favorite features of zsh is auto-complete, especially when I'm completing a filename on a networked machine. But how do you include wildcards (like *) and have it auto-complete on the remote machine?
For instance, say I have file1, file2, and file3 residing on a server; I want to copy all those files to my local machine, so I enter
scp server:~/fi<tab>
zsh then correctly auto-completes to
scp server:~/file
but then when I try to wildcard
scp server:~/file*<tab>
all it does it beep at me (it works correctly if the file paths are local). Is there a set of zsh options that makes this work? I found GLOB_COMPLETE and EXTENDED_GLOB, but the best I could do with any combination of those was to auto-complete a single match, or cycle through all matches, but not expand the auto-complete to all matches (as it does on the local command line). Is that actually possible?
Thanks!
randy
As I've mentioned at superuser: Think setting GLOB_COMPLETE should change this.
setopt GLOB_COMPLETE
From man zshoptions:
GLOB_COMPLETE
When the current word has a glob pattern, do not insert all the words resulting from the expansion but generate matches as for completion and cycle through them like MENU_COMPLETE. The matches are generated as if a ‘*’ was added to the end of the word, or inserted at the cursor when COMPLETE_IN_WORD is set. This actually uses pattern matching, not globbing, so it works not only for files but for any completion, such as options, user names, etc.
Note that when the pattern matcher is used, matching control (for example, case-insensitive or anchored matching) cannot be used. This limitation only applies when the current word contains a pattern; simply turning on the GLOB_COMPLETE option does not have this effect.
Your example works perfectly fine for me. I don't know what makes it work on my system, but here's what I have set:(
alwaystoend
cbases
extendedglob
interactive
interactivecomments
monitor
shinstdin). And my .zshrc has:
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
zstyle ':completion:*' max-errors 1 numeric
zstyle ':completion:*' menu select=2
autoload -Uz compinit zsh-mime-setup
compinit
I've the same problem !
I suceed with the follwing command:
scp "user#server:/dir/*" localdir
double quote escapes the completion.

Why is psql inserting a tilde when I press any of the keys in the Home key cluster?

I'm using psql 8.2.3 on FreeBSD. Every time I press Insert, Home, Delete, End, Page Up or Page Down, a tilde (~) character is inserted instead of performing the expected function of the key. Why does this happen and how can I fix it?
As mentioned in Endlessdeath's answer, this turned out to be a key mapping problem with the operating system (FreeBSD), not psql. You can make these keys work as expected by creating or adding to a configuration file for inputrc.
You can create a file named .inputrc in your home directory with the following:
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
Alternatively, you can create a global file for all users. A common practice for this is to create or add to the file at /usr/local/etc/inputrc the same lines as above and then export the variable in /etc/profile:
export INPUTRC=/usr/local/etc/inputrc
Ensure that /etc/profile is sourced by your shell (most do by default) and you're good to go. Note that the file won't be sourced until you log out and in again.
Here are some other resources for this problem:
http://bsdpants.blogspot.com/2007/08/make-home-and-end-keys-work.html
http://www.cyberciti.biz/tips/freebsd-how-to-customized-home-del-insert-keys-for-bash-shell.html
http://www.ibb.net/~anne/keyboard.html
That shouldn't be a psql problem - it's os specific.
A quick search on google could help.