Bash Substring File Completion - substring

Does bash partial/substring file completion similar to what zsh does?
That is, instead of requiring the user to enter a prefix of the filename, then tab; the user can also enter a substring of the filename, then tab.
Say a directory contains a file abcdef, then not only would ab<tab> complete to this filename, but also bc<tab> and cd<tab> and so on.

If a directory contains the file abcdef, then you can enter *bc* and then hit the TAB key, and it will complete. Of course, zsh can do it without the *, so it's not the same thing.

Related

Add trailing slash in tcsh completion of directory symbolic links

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.

Task Scheduler | I am trying to schedule a .ps1 file but every time the scheduler runs a pop window appear "How Do you want to open this file?"

Here's a screenshot from scheduled task action settings
First of all make sure the path used for powershell is correct (best option in my opinion is to click Browse... and select the program with the dialog window instead of manually inserting the full path, if that's what you did).
In second place, change Add arguments (optional): to -File "D:\TM1 Model\Test GIIS\...\yourfilename.ps1", please note you should use double quote since the full path contains spaces; again, make sure the full file path is typed correctly.
There should be no need to insert the full path in the in the Program/script box. Most people don't even know where it is.
For all the PowerShell scripts that I run on servers I only type powershll.exe and it works.
I agree with Giacomo (Calvin?), the value in the Add Arguements box needs to be in quotes if you have spaces in the folder or file name. ie -File "C:\Batch Files\checkdisk.bat"
The -File argument is telling PowerShell the file you want powershell.exe to run.

How to add keyboard shortcut for custom nemo action?

I have an custom nemo action as explained here:
https://wiki.archlinux.org/index.php/Nemo#Nemo_Actions
How can I add an shortcut for this action?
(If it can be done adding a line in ~/.gnome2/accels/nemo, then I have the additional problem that on my system this file is auto generated on every reboot, so editing something here will not help. I have Cinnamon 3.2.7 and nemo 3.2.2.)
Any suggestions? Thanks in advance! :)
Nemo Action
First, you should place the myaction.nemo_action under ~/.local/share/nemo/actions/.
Then, to make a keystroke put an underscore _ in front of the letter you want. For example in the Hello _Shortcut the s is the key. So you press the right-click and then s.
Bellow is an example of my action to open files and directories with Atom:
# Custom action for Nemo File Manager for Cinnamon.
# Adds right-click open file/files or directory with Atom.
# Place it under: ~/.local/share/nemo/actions/atom.nemo_action
# For more info: https://github.com/linuxmint/nemo/blob/master/files/usr/share/nemo/actions/sample.nemo_action
[Nemo Action]
Active=true
Name=Open in _Atom
Comment=Open %F in Atom
Exec=atom %F
Icon-Name=atom
Selection=any
Extensions=any;
Dependencies=atom;
Quote=double
Global Shortcut
If you want a global shortcut, you should use the Cinnamon Keyboard setting under the System settings, go to the second tab and add your custom shortcut.
Or, if you prefer more control over CLI you can use the dconf. For example, the bellow configuration will add the shortcut Shift><Alt>a
/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/name
'Open Atom'
/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/command
'atom'
/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/binding
['<Shift><Alt>a']
/org/cinnamon/desktop/keybindings/custom-list
['custom0']
Am trying to respond to Duncan Marshall but the post ended up in the mainthread. Yes, it's possible. Your file ~/.gnome2/accels/nemo can contain a line such as the following, which would execute a scrip file named edit.sh when F4 is pressed. The scripfile must be located in this special path (~/.local/share/nemo/scripts) and it must be enabled via a checkbox in User Interface>Edit>Preferences>Plugins>Scripts. Also i was unable to specify a script path such as ~/... instead of /home/username... When the syntax in the accels/nemo file is incorrect, nemo will prepend the incorrect line with ; and it will also delete the keycode at the end of the line and it also likes to resort lines in the accels file. I will also dismiss a line when the keycode was already used in another line. So it couldn't be more tricky to get this right.
(gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sUSERNAME\\s.local\\sshare\\snemo\\sscripts\\sedit.sh" "F4")
the script file might look like this
#!/bin/bash
export FILETOEDIT="$1"
FILEOWNER=$(stat -c %U "$1")
if [ "$FILEOWNER" = "$USER" ]; then
subl "$1"
else
sudo xed -w "$FILETOEDIT"
fi

How to view content of emacs autosave file

How do I directly see the content of an emacs autosave file, without implementing a file recovery operation?
That is, suppose I created a file with 'emacs foo', then emacs crashed, so I'm left with no file named 'foo' (since it never was saved) but with a file '#foo#'. When I type 'more #foo#', I get "Missing filename", as though the more command doesn't even see the #foo# part of the command.
I just want to see the text in #foo# so I can copy it out by hand without risking something going wrong in the file recovery process (eg #foo# getting overwritten by a new autosave operation).
(I'm using Terminal on OSX.)
Bash or another shell use '#' as comment character, try :
more "#foo#"

How to open a file without typing its entire name?

I want to be more comfortable with CLI, so I need practice. :D
I have a directory and within it I have more of them. I use ls to find their name, but the one I want to change into has a very long name.
Is it possible to change to that directory without typing his entire name?
Try to type few chars of that name and press Tab once to complete that name.
If it doesn't complete, press Tab twice to see available names that start with the character sequence that you entered. Then, add few more chars, so that sequence is unique for that name and press Tab to complete.