1

I would like to know if there is any plugins and/or utilities that could make my life MUCH MORE easier.

When moving from folder to folder through console, I can use the Tab key on my keyboard to autocomplete a folder, look for a folder (double tap) or simply to express that I want to go "forward" with my searches.

When coding, the Tab key is used to "push" the code "forward" or to the right. To "pull" the code "backward", you can use the combination of Shift+Tab keys.

Is there an equivalent for, as an example, pressing the Shift+Tab keys to write ../ in the console for me? Or to let me know I'm at the root level and that I can't go "backward" anymore?

Examples of usage:

Case 1:

user@server:/$ cd ~/Desktop/folder1/

after Shift+Tab

user@server:/$ cd ~/Desktop/(Remove the last written folder. No more backspace spam!! :D )

Case 2:

user@server:/$ cd

after Shift+Tab

user@server:/$ cd (Because I'm at root and can't go back)

Case 3:

user@server:/home/Desktop/folder1$ cd

after Shift+Tab

user@server:/home/Desktop/folder1$ cd ../ (Because I can go back to Desktop)

I know that sounds lazy. I know I'm lazy.

Anyways, thanks for the suggestions! (:

Edit: Just to be clear. I gave as an example the cd command, but what I want could be applied to any command/executable. It would be considered a basic use just like Tab is used to autocomplete.

  • If you want to be lazier, use cd .. instead of cd ../ and save one keystroke :) – WinEunuuchs2Unix Apr 19 '19 at 19:29
  • What I'm saying is that with an additionnal feature such as this one, you could almost only use <kbd>Tab</kbd> and/or <kbd>Shift</kbd>+<kbd>Tab</kbd> to go through directories :P But hey, I understand that some folks don't care about that possible upgrade. – LoukMouk Apr 22 '19 at 14:08
  • Luckily I learned how to do it a week ago and just needed to fine-tune a solution for this question. – WinEunuuchs2Unix Apr 22 '19 at 15:43
  • 3
    crosspost – bummi May 7 '19 at 12:19
  • @bummi I've posted this on AskUbuntu, SuperUser and Unix&Linux! (: I hope to get more points of view from yall :P – LoukMouk May 7 '19 at 12:21
2

Create this file /home/$USER/.inputrc with the following:

# ~/.inputrc - complements /etc/inputrc - global inputrc for libreadline
# April 15, 2019
# See readline(3readline) and `info rluserman' for more information.

$include /etc/inputrc

# Insert key to togged overwrite-mode
"\e[2~": overwrite-mode

# April 22, 2019 AU Q&A: https://askubuntu.com/q/1135306/307523
# Make Shift-tab act like "cd ../" (move to parent directory)
"\e[Z": "cd ../"

Save the file and open a new terminal.

Now you can use Shift+Tab to send cd ../ to the terminal.

Also included in the settings you can press Insert key to toggle between character overwrite (replace) mode and insert mode.

  • Do you know if there's any way to make this into a switch case taking what's already writen in console, ex: myExe.exe folder0/folder1/file0, and determine what case to use? Shift+Tab combinaison on this line of command would change to myExe.exe folder0/folder1/? (: There has to be a way right? Since the Tab key, when hit twice in a folder containing multiple subdolders, is kinda like the ls command, but when there's already letters to specify the wanted folder, it autocompletes the said folder name (kinda like a switch case) – LoukMouk Apr 22 '19 at 16:46
  • 1
    When you look at /etc/inputrc you will see there are $if statements to determine a given state and react in two different methods. Such programming skills are above my AU paygrade though :( Hopefully someone else can take what I've posted and run with it :) – WinEunuuchs2Unix Apr 22 '19 at 17:16
  • Thanks allot for the info! (: I'll certainly use the code you wrote as a base to what I want to accomplish! – LoukMouk Apr 22 '19 at 17:42
  • If you improve the code remember to post your own answer and click the grey check mark to it so others know your solution works. I wish you good luck and good programming! – WinEunuuchs2Unix Apr 22 '19 at 18:01
  • The answer you wrote gave me knowledge on how to code a shortcut. (Shift + Tab writes cd .. in the console) Which is answering part of my question but not everything. It does not tell me how to change myExe myFolder/myChildFolder/ to myExe myFolder/ and many more use case and/or how to read and change the myFolder/ section directly from/to the console. Thank you for your time! – LoukMouk May 6 '19 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.