LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-20-2012, 05:50 PM   #1
pillows
LQ Newbie
 
Registered: Jan 2012
Posts: 4

Rep: Reputation: Disabled
Home Key-like shortcut/hotkey


Hi, I am sort of new to linux, but more of an intermediate. Anyways what I want to do, and cannot find in google searches or on here, is basically create a shortcut key that will function the same way the ~ key does for your home directory. Except that you can choose what directory to set it to. Alias doesn't work because it is a command so you cannot cd into it, a variable is annoying because you have to type the $ before it. Is there any way to say for example have something like this? Say your directory is

Code:
/my/really/long/and/annoying/to/fully/type/out/every/time/path
and you want to make it so that the "@" symbol will take you there, but also know that it is a directory (basically terminal interprets it as the directory path) so you can therefore...

Code:
cd @
terminal goes to /my/really/long/and/annoying/to/fully/type/out/every/time/path

P.S. and alias='cd /path' is NOT what I am looking for. Because I want to use it in commands other than cd as well.

Last edited by pillows; 01-20-2012 at 05:52 PM.
 
Old 01-20-2012, 09:34 PM   #2
barnac1e
Member
 
Registered: Jan 2012
Location: Moorhead, Minnesota, USA (birthplace of Slackware, ironically)
Distribution: openSuSE 13.1 - KDE
Posts: 234
Blog Entries: 1

Rep: Reputation: 9
This just an idea but the "Windows" key I have learned is called a "Super" key and hitting it plus another "key for whatever app or process" is your shortcut process. Try doing a Google search with "Super+, key, Linux, Arch Bang or Crunchbang" and type all of that at one time because these two distros use that very Super key a lot.
 
Old 01-20-2012, 09:59 PM   #3
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
I'd do that by putting a special alias directory into CDPATH and put my aliases there as symlinks.
Code:
$ mkdir ~/diraliases
then in .bashrc
Code:
CDPATH=${CDPATH+$CDPATH:}/home/you/diraliases
Then
Code:
$ ln -s /path/to/your/@/dir ~/diraliases/@
And cd @ gets you there.
 
Old 01-22-2012, 02:00 PM   #4
pillows
LQ Newbie
 
Registered: Jan 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Yes but that still doesn't give you any other functionality. What if you wanted to 'rm' something like @/thisthing.txt or 'mkdir' @/newfolder
 
Old 01-22-2012, 05:35 PM   #5
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
You want @ to mean /very/long/pathname in *every* context? cd is a shell builtin, the shell knows what that does and can treat its arguments appropriately. The other commands you mention aren't; you'd have to modify the shell itself to understand in which contexts you want a leading @ interpreted as a directory alias.

The closest I can reasonably get to what you want is to have an @ command in your history, and use !@:1 or !@:$ instead:

Code:
~$ @ /home/jthill/fugly/pathname
@: command not found
~$ echo !@:$
echo /home/jthill/fugly/pathname
/home/jthill/fugly/pathname
~$ mkdir -p !@:1
mkdir -p /home/jthill/fugly/pathname
~$
... but that's not much different than making an @ link in your home directory and just using ~/@ ...

Last edited by jthill; 01-22-2012 at 05:37 PM. Reason: added last line
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Need a temporary hotkey or shortcut in openoffice writer in linux littlejoe5 Linux - Software 1 07-13-2010 10:47 PM
kill key shortcut jessica_lilly Linux - Desktop 4 11-07-2007 05:13 PM
Hotkey annoying me + home dir doesnt display sometimes Geminias Linux - Newbie 7 08-17-2007 03:12 PM
x server kill application keyboard shortcut/hotkey hypermegachi Linux - Newbie 2 07-25-2004 03:37 PM
shortcut key for rh ? toships Linux - Newbie 1 04-09-2004 03:17 AM


All times are GMT -5. The time now is 06:22 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration