LinuxQuestions.org
Visit Jeremy's Blog.
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 09-17-2009, 08:22 AM   #1
jlillywh
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Rep: Reputation: 0
create a "bookmark" for navigating filesystem from the linux command line


I think I need to use the ln -s command for this but not sure. Could someone give me a good example of a way to make it so I don't have to keep re-typing

cd ~Dropbox/programming/ruby/function_library/pond_design

once per hour?

I would really like to just type

cd pond_design or something else shorter

What is the best way to do this kind of thing, in general?
 
Old 09-17-2009, 08:28 AM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Code:
alias pond="cd ~Dropbox/programming/ruby/function_library/pond_design"
If the above works, you now just type pond to go to that directory.

You can add this to your .bash_profile or similar file, so it will remain in effect after reboot or whatever.

Sasha
 
Old 09-17-2009, 08:42 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,615
Blog Entries: 26

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
Hi,

I would like to add to what Sasha posted is that you could setup a .bashrc & .bash_profile for your user;

Code:
sample .bash_profile;

~$ cat .bash_profile
# .bash_profile       <<< Begin of File
#08-30-06 12:21
#
# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi                    <<< End Of File (EOF)
Code:
sample .bashrc;
:~$ cat .bashrc

#.bashrc          <<<< begin of file
#08-30-06 12:20 

# Add bin to path

export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# Custom prompt
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

#08-29-06 11:40

if [ `id -un` = root ]; then
   PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
 else
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi

#
# Add color
eval `dircolors -b`

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'
alias pond="cd ~Dropbox/programming/ruby/function_library/pond_design"

#08-29-06 11:50

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
   trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
#   trap 0 rm -f ~$LOGNAME/.bash_history <<< End Of File (EOF)
The .bashrc is very useful!
 
Old 09-17-2009, 12:56 PM   #4
jlillywh
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Original Poster
Rep: Reputation: 0
create new .bash_aliases

That is a great idea. Thank you. However, I'm having a hard time understanding everything you are doing with the .bashrc and .bash_profile.

Is there a way to simply create a .bash_aliases and put them in there?

I did this:

# User defined aliases
alias pond="cd ~/Dropbox/programming/ruby/function_library/pond_design"

and saved that in .bash_aliases but when I type pond the bash command is not recognized. Can you explain what I have to do so that it is recognized?

Thank you!
 
Old 09-17-2009, 01:17 PM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,615
Blog Entries: 26

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
Hi,

Quote:
Originally Posted by jlillywh View Post
That is a great idea. Thank you. However, I'm having a hard time understanding everything you are doing with the .bashrc and .bash_profile.

Is there a way to simply create a .bash_aliases and put them in there?

I did this:

# User defined aliases
alias pond="cd ~/Dropbox/programming/ruby/function_library/pond_design"

and saved that in .bash_aliases but when I type pond the bash command is not recognized. Can you explain what I have to do so that it is recognized?

Thank you!
If you copy each of the text samples to their own file then you can use them. The first sample is a '.bash_profile' where I test for the existance of '.bashrc' then execute if there. The second sample is '.bashrc' that you would have your commands that you wish available. The first part test for 'root' if so then the colorized prompt is set red with the prompt information. Otherwise it is set to green for a normal user for prompt. Then the alias is setup. At the close is just for cleanup.

So if you save each sample to the required files for '.bashrc' and '.bash_profile' you would have things set for the next time you enter the console. There after for each time you enter your console you would have things setup this way until you change or remove the files.
 
Old 09-17-2009, 01:45 PM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
~/.bashrc and ~/.bash_profile are two bash initialization files, ~/.bash_aliases is not, and bash has no means to know that. Bash can't open every single file in your home directory to see what's inside of it.

Bash will source ~/.bashrc when it's launched in a non-login interactive mode, for example, when you use an xterm or a similar terminal emulator. ~/.bash_profile will be read automatically when you use bash as a login shell, for example when you login in command line instead of a graphical login manager.

Hence, all the bash related stuff goes either into ~/.bashrc, ~/.bash_profile, or both. Or, if you want to set it globally, into /etc/profile. However, I don't understand what the difficulty is. It isn't any more complicated to create a file called ~/.bashrc than it is to create one named ~/.bash_aliases...
 
Old 09-17-2009, 02:34 PM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Well, if you want a separate file for aliases, it's also simple enough to source that interactively or from ~/.bashrc. Just type '. ~/.bash_aliases' or add it to your ~/.bashrc.

You might also look into popd/pushd, cdable_vars, and CDPATH.

CDPATH="whatever_you_like:~Dropbox/programming/ruby/function_library/"
cd pond_design
 
Old 09-17-2009, 02:52 PM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Yes, there are thousands of ways to make it more complicated.
 
Old 09-17-2009, 03:23 PM   #9
jlillywh
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Original Poster
Rep: Reputation: 0
onebuck, thank you. I simply copied your scripts - created .bashrc and .bash_profile. It works like a charm.
 
Old 09-18-2009, 06:05 AM   #10
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: Slackware®
Posts: 12,615
Blog Entries: 26

Rep: Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987Reputation: 1987
Hi,

I'm glad it worked for you. 'KISS' is always the best!

BTW, as the OP you can mark the thread as [SOLVED] via the Thread Tools. Courtesy to others.
 
  


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
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
have livecd of 'Linux Gentoo' how do i get past the "livecd root #" command line? randell6564 Linux - Distributions 11 11-20-2005 12:31 PM
cdrecord command-line parentheses "(" ")" coolingtower Linux - Software 1 10-28-2005 11:49 AM
The best command for "extracting" a loopback filesystem Tsuroerusu Linux - Software 2 02-12-2005 07:58 AM
"basically start of using linux by command line " AAT Linux - Software 1 11-02-2003 06:47 AM


All times are GMT -5. The time now is 03:12 AM.

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