*nix users - what are some good aliases for you shells?

SinNisTeR

Diamond Member
Jan 3, 2001
3,570
0
0
just wanna see what some people have going on with their shells, any cool neat stuff.. just looking for some ideas.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
I don't. Generally. I move between systems that I don't necessarily own/run often enough that if I got used to an alias it would screw me up somewhere else.
 

SinNisTeR

Diamond Member
Jan 3, 2001
3,570
0
0
so very true.. even though i have aliases i still end up typing the whole command itself

one thing that screws me up is going into a windows command prompt and typing 'ls'. that ALWAYS kills me.
 

Klixxer

Diamond Member
Apr 7, 2004
6,149
0
0
Originally posted by: n0cmonkey
I don't. Generally. I move between systems that I don't necessarily own/run often enough that if I got used to an alias it would screw me up somewhere else.

Same here.
 

AkumaBao

Golden Member
Aug 14, 2001
1,438
0
0
Only thing I change is my prompt. I did alias my color at one time, but that got really really annoying with transparent windows. About the only ones I use are the ones I type by accident that FreeBSD has by default.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
I use tcsh, so the syntax won't match bash:

alias pico 'pico -w'
-word-wrapping behavior, I think

alias ls ' ls --color'
alias sl ls
alias ll 'ls -l'
alias la 'ls -a'
-obvious


alias cd 'pushd \!* > /dev/null'
set pushd_silent
-lets me use popd to go back to previous directories. very handy. if you don't set pushd_silent, it prints stuff every time you cd though.

alias cd.. 'cd ..'
-typo fix

alias vi vim
alias more less
alias l less
alias m more
alias e 'xemacs'
alias g '/bin/grep'

alias rm 'rm -i'

alias xterm 'xterm -sb -sl 2048'
-scrollbar, 2048 line history.

alias bc 'bc -l'
alias calc 'xterm -e "bc" -l'

alias gzcat 'gunzip -c'
-I didn't know of zcat when I added this one

edit: I set my prompt to username@machinename[img]i/expressions/face-icon-small-happy.gif[/img]irectory so I know where I am. (tcsh lets you jsut show the last few dirs, so it doesn't get insanely long)
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
I have a alias setup for vi for systems that have a choice between a "real" vi clone versus Vim.

alias vi="vim"

And I like colors:

alias ls="ls --color=auto"

Then I have a alais to start my second X server I use for gaming. I have 2 layouts and 2 sets of video card descriptions setup in my XF86Config file. One is the default twinview mode, and the other is a single monitor mode I use for gaming.

alias gamex="X -layout Gaming :1.0"

and I have the infamous:
set -o vi

And that's about it. Time to time I'll setup other aliases, but they are usually for something specific that I end up using for a special purpose for a while then forget about.


Although I am a bit proud of my special little .bashrc color sceme thingy I have setup so that I can play around with and make different colors when I get bored. A lot of it was originally pulled from a webpage somewere, but I cleaned it up and refined it and added a couple notes so that I could remember what is going on.

# /etc/skel/.bashrc:
#Drag's Bash startup settings for interactive situations.

# colors for ls, etc.
alias ls="ls --color=auto"
alias gamex="X -layout Gaming :1.0"

#consule colors!
RED="\[\033[0;31m\]"
LRED="\[\033[1;31m\]"
GRN="\[\033[0;32m\]"
LGRN="\[\033[1;32m\]"
BLU="\[\033[0;34m\]"
LBLU="\[\033[1;34m\]"
PUR="\[\033[0;35m\]"
LPUR="\[\033[1;35m\]"
CYA="\[\033[0;36m\]"
LCYA="\[\033[1;36m\]"
YEL="\[\033[0;33m\]"
LYEL="\[\033[1;33m\]"
BRN="\[\033[0;33m\]"
GRY="\[\033[1;30m\]"
LGRY="\[\033[0;37m\]"
WHT="\[\033[1;37m\]"
NON="\[\033[0m\]"

# backgroundcolors
BGRY="\[\033[40m\]"
BRED="\[\033[41m\]"
BGRN="\[\033[42m\]"
BYEL="\[\033[43m\]"
BBLU="\[\033[44m\]"
BPUR="\[\033[45m\]"
BCYA="\[\033[46m\]"
BWHT="\[\033[47m\]"

# Things BASH understands:
# \a an ASCII bell character (07)
# \d the date in "Weekday Month Date" format
# \e an ASCII escape character (033)
# \h the hostname up to the first `.'
# \H the hostname
# \j the number of jobs currently managed by the shell
# \l the basename of the shell's terminal device
# \n newline
# \r carriage return
# \t the current time in 24-hour HH:MM:SS format
# \T the current time in 12-hour HH:MM:SS format
# \@ the current time in 12-hour am/pm format
# \u the username of the current user
# \v the version of bash (e.g., 2.00)
# \V the release of bash, version + patchlevel
# \w the current working directory
# \W the basename of the current working dir
# \! the history number of this command
# \# the command number of this command
# \$ if the effective UID is 0, a #, otherwise a $
# \\ a backslash

PS1="\n-{$RED\u$LGRN@$GRN\h$NON}-$PUR \t$GRN\n$BRED\w >:$NON "
export PS1

set -o vi


So I just scp that to all my computers and use it. For my root user I'll use it too, but I'll do something like make the background red so that It's visually obvious that I am root, and not my normal user.

I also use to have a PATH statement, and still do on some computers. It was mostly because when I would to "sudo su" I wanted to have the PATH all set up before hand to use system commands. However since then I learned that if you add a "-" after the "su" then reverts to using root's enviroment like you just logged in using root instead of just becoming a super user. So now I go: "sudo su -"

Here is what I use for root's prompt:
PS1="$BRED\n-{$WHT\u$LGRN@$GRN\h$NON}-$PUR \t$GRN\n$BRED\w > "
export PS1


 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
While doing an hour's worth of work in 8 hours last night (bad night :|), I ended up using 1 alias: ls="ls -F".
 

Yossarian451

Senior member
Apr 11, 2002
886
0
0
I am pretty new at linux and I was wondering with say the javac and java commands if I could assign an alias that would first run javac then java on the file, but somehow it would no run java if there was an error and remove the .java from the end of the filename. I would probably call it something like javer.

But I was fairly certain that there wasnt that much leeway built into an alias. Since that seems a little complicated for a simple "when I say this I mean that" type statment. But like I said, I am new at linux and I have high hopes.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
That would probably entail a script.


I am not sure what your talking about with java and javac. Not to familar with java. But a bash script to do something like that would be easy to do. Then you stick it in a path (I use ~/bin for my scripts).

Something like:

#! /bin/bash
# drag's jtry script

if javac $1 ; then
java $1
else
echo "error"
mv $1 ${1//.java/}
fi

Something like that. Make that executable, stick it in a folder in your PATH.

Then say if you wanted to run cowpower.java then you would go:

jtry cowpower.java

And I think that will work, I haven't tested it any though.

When you run a script, arguments get assigned to 1, 2, 3, etc (thru 9) variables.

The ${variable//string/replacementstring} you can use to replace a string of text in a variable with a different string.

(edit: only in that instance, the actual vairable will remain untouched. It just changes the output of the variable...
For a example try these commands at the command line.

POO=cowlick
echo $POO
echo ${POO//lick/pie}
echo ${POO:3}
echo ${POO:3:1}
echo $POO
)

Also the
if commandname
is a test, if the command runs and returns with a 0 (means it ran successfully) then bash will run the command in then "then" statement, otherwise it will run the command in the "else" statement if it exists.

So on and so forth. Bash is fairly powerfull scripting language, although for complex things your usually better off using something like perl or python.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: drag
That would probably entail a script.


I am not sure what your talking about with java and javac. Not to familar with java. But a bash script to do something like that would be easy to do. Then you stick it in a path (I use ~/bin for my scripts).

Something like:

#! /bin/bash
# drag's jtry script

if javac $1 ; then
java $1
else
echo "error"
mv $1 ${1//.java/}
fi

Something like that. Make that executable, stick it in a folder in your PATH.

Then say if you wanted to run cowpower.java then you would go:

jtry cowpower.java

And I think that will work, I haven't tested it any though.

When you run a script, arguments get assigned to 1, 2, 3, etc (thru 9) variables.

The ${variable//string/replacementstring} you can use to replace a string of text in a variable with a different string.

Also the
if commandname
is a test, if the command runs and returns with a 0 (means it ran successfully) then bash will run the command in then "then" statement, otherwise it will run the command in the "else" statement if it exists.

So on and so forth. Bash is fairly powerfull scripting language, although for complex things your usually better off using something like perl or python.

The if command stuff has a bunch of options. I think if -X command checks to make sure it is executable, not sure though. I'd have to check the manpage or one of my older scripts. It's been a while.

And ~/bin is sometimes already in the $PATH. It's fairly standard, although I use ~/admin.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Ya. In my .bash_profile file Debian puts some script code to detect the prescence of commonly used fils/folders for this stuff. For your conveinence only, they are commented out by default:

From /etc/skel/.bash_profile (stuff in the /etc/skel is installed by default whenever you make a new user, BTW, for people who don't know that yet.)
# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/login.defs
#umask 022

# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# the rest of this file is commented out.

# set PATH so it includes user's private bin if it exists
#if [ -d ~/bin ] ; then
# PATH=~/bin:"${PATH}"
#fi

# do the same with MANPATH
#if [ -d ~/man ]; then
# MANPATH=~/man:
# export MANPATH

 

EmperorRob

Senior member
Mar 12, 2001
968
0
0
alias ls='ls --color=auto'
alias l='ls -lhF'
alias lt='ls -lt'
alias l.='ls -d .[^.]* 2> /dev/null'
alias ll.='ls -lhd .[^.]* 2> /dev/null'

This one I can't live without
alias ?='echo $?'

alias dfh='df -h'

set my copy,move and rm commands to verbose for large operations
alias cp='cp -v'
alias rm='rm -v'
alias mv='mv -v'
 

Ameesh

Lifer
Apr 3, 2001
23,686
0
0
alias ls = 'ls -ltrah --color=auto'
and then some randmon stuff for ssh and development work
 

JoLLyRoGer

Diamond Member
Aug 24, 2000
4,154
4
81
alias shut='shutdown -g0 -y'
alias shit='echo Why don't you try "shut" instead of cussing at me!'
alias t1='tcp stop'
alias t2='tcp start'
alias booty='shutdown -g0 -y -i6'
alias m1='mount /dev/fd0135ds18 /mnt'
alias m2='umount /mnt'
alias mcd='mount -r /dev/cd0 /tmp/cdrom'
alias umcd='umount /tmp/cdrom'
alias rlink='/etc/conf/cf.d/link_unix -y'
alias c1='cat /etc/hosts'
alias c2='cat /etc/ppphosts'



Just a few I added to my /.profile
JR..

 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |