LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-16-2010, 07:08 PM   #1
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Xubuntu Trusty
Posts: 77

Rep: Reputation: 18
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?
 
Old 06-16-2010, 07:45 PM   #2
Bratmon
Member
 
Registered: Jul 2009
Location: 75.126.162.205:80
Distribution: Arch / Mint 17
Posts: 297
Blog Entries: 3

Rep: Reputation: 50
Code:
!!
3 char min
 
Old 06-16-2010, 09:00 PM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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.
 
Old 06-16-2010, 09:21 PM   #4
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
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.
 
Old 06-24-2010, 04:18 PM   #5
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Xubuntu Trusty
Posts: 77

Original Poster
Rep: Reputation: 18
Exclamation

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?
 
Old 06-24-2010, 04:41 PM   #6
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,836
Blog Entries: 1

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
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
 
Old 08-09-2010, 03:28 PM   #7
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Xubuntu Trusty
Posts: 77

Original Poster
Rep: Reputation: 18
[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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete button does not work in ZSH command-line Scotteh Debian 1 02-04-2013 03:36 AM
When empty, cannot open cd/dvd door with button or command line. chuckbuhler Linux - Hardware 34 12-28-2010 03:26 PM
Trying to remove the shutdown reboot button from the command line fcfury Linux - Newbie 1 07-10-2009 09:02 AM
how do I specify the current directory on the command line powerpleb Linux - Newbie 3 06-11-2008 05:28 AM
Command line way to click a mouse button. danielw Linux - General 6 09-02-2003 03:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration