LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   command line 'last directory' button? (https://www.linuxquestions.org/questions/linux-newbie-8/command-line-last-directory-button-814601/)

CQ1ST 06-16-2010 07:08 PM

command line 'last directory' button?
 
hi, I'm a linux-cli-newby

in the command line there's a button (tab) for autocompleting commands and I'm pretty sure linux has a button that prints the last directory I used/typed whatever?

Bratmon 06-16-2010 07:45 PM

Code:

!!
3 char min

evo2 06-16-2010 09:00 PM

Pressing the up arrow on the keypad should display last command entered.

As Bratmon states, "!!" will also, but that would require more than one keystroke or "button".

To actually cd to the last directory:
Code:

cd -
Evo2.

rikijpn 06-16-2010 09:21 PM

yeah, going to the last directory would be
Code:

cd -
You can also have a directory stack (a list of directories), and be able to access lots of directories without having to type the whole path every time.
For example:
Code:

pushd ~ #sends your home dir to the dir stack
pushd #goes to the sent dir (home)
pushd #goes back
pushd /etc/somedir/ #now you have 3 dirs in the stack
pushd +2 #goes home again

etc. Depending on your shell, you can also go to the previous command using Ctrl-P btw. Which is a bit faster than pressing the arrow keys.

CQ1ST 06-24-2010 04:18 PM

hang on a minute, I need to stipulate the usage ::
(I'm 'sure' that I stumbled on this some time in the past)

ls /etc/rc*
cat /etc/rc4.d/K74bluetooth | less
mv [button for- ] /etc/rc4.d/K74bluetooth [button again] /etc/rc4.d/K74bluetooth[type].old

do you see what I mean to use this button for here?

sycamorex 06-24-2010 04:41 PM

There's the $_ variable to return the last argument or the combination Esc+.
As it prints the last argument of the previous command line, it would only work as long as you get rid of | less.


HTH

CQ1ST 08-09-2010 03:28 PM

[edit] haha yeah bratmon's totally correct! ("I'm really happy I asked and I just used it further!"
$ls -R !!/plugins)[edit]

okeydoke - I've stumbled on it again yay! it is alt-.(alt->) and it doesn't work too long into bash history but in the example:

$ls /usr/lib/mozilla
$ls -R (Alt-. equals)/usr/lib/mozilla

it works a treat in typing the address rather than the last command,
i just wish that i could make this kind of "address type-shortcut" stay there longer!


All times are GMT -5. The time now is 07:19 AM.