image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old March 1st, 2004, 10:37 AM
Professional Crastinator
 
Join Date: Jun 2002
Location: I'll tell you later
Posts: 366
Thanks: 0
Thanked 0 Times in 0 Posts
tk4two1 is on a distinguished road
simplifying commands?

I was wondering how to go about simplifying my most used commands. Basically if I want to run a command like
Code:
ls -a -s -l
but I only want to type
Code:
list
or something like that, how do I go about this? Is it using links and what not? Please help me. Thanks!
Reply With Quote
  #2  
Old March 3rd, 2004, 11:13 AM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
use the "alias" shell builtin. So, by making a file in your home dir called .bash_profile, and putting lines in it like
alias list='ls -a -s -l'
you can save some typing

Incidentally, that file is only read once when bash starts, so that will apply only to terminal windows opened since you change the file
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
  #3  
Old March 3rd, 2004, 05:48 PM
Professional Crastinator
 
Join Date: Jun 2002
Location: I'll tell you later
Posts: 366
Thanks: 0
Thanked 0 Times in 0 Posts
tk4two1 is on a distinguished road
thanks That was exactly what I was looking for!

By the way what other types of entries can I put in the .bash_profile?

Last edited by tk4two1; March 3rd, 2004 at 05:55 PM.
Reply With Quote
  #4  
Old March 3rd, 2004, 06:09 PM
Registered User
 
Join Date: May 2002
Location: New Zealand
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
scaryfish is on a distinguished road
Pretty much anything you can write on the command line, I believe. Oh, by the way
ls -a -s -l
can also be written
ls -asl
__________________
=)
<><
public key id: EE4B2E09
Reply With Quote
  #5  
Old March 3rd, 2004, 09:21 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
Yes, you can put anything you want in there - it's just a script that gets run whenever the shell starts.

I don't actually use bash - I got set in my ways in OS X PB - 10.2 where tcsh was the default shell. I decided to try bash for a while, and made this bash_profile before I got fed up with it:

Quote:
#shell behaviour

# set prompt string to something informative...
# bold seems to be messing up character wrapping in Apple's terminal. Errr
# but we can still write to the title line without problems.

#bold=`tput bold`
#plain=`tput sgr0`
bold=''
plain=''
titlebar='\[\033]0;\u@\h:\w\007\]'

PS1="${titlebar}${bold}$? \A \u@\h:\W \$${plain}"
export PS1

# make tab completion more useful
set autolist = ambiguous

##conveniences
alias ll='ls -al'
alias l='ls -FH'
alias ..='cd ..'
alias ps2pdf='pstopdf'
alias du='du -h'

# line <number> <filename>
line() {
cat $2 | sed -n "$1 p"
}

mkcd() {
mkdir $1
cd $1
}


##environmental friendliness
#why vi?
export EDITOR=nano
# set this, and manpages don't close without explicit 'q'
export PAGER=less
Should give you at least an idea of what sort of thing can go in there
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
Reply

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 08:43 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.