For those of you who don't know, .alias and .funtion are two files that get loaded at user logon time. Actually when you open a terminal for command line operations, which are their primary purpose. Aliases are just that... different names for some of the system commands ... only modified to suit your needs. Some of these commands require some substantial typing in order to include all the options and arguments. So the Linux guys decided to incorporate aliases, to alleviate users of some typing and memory chores. Remembering all those options can be trying.
The functions are an extension of the alias files. These involve a little more input. They are like little procedures or programs that you can execute with, or without, arguments.
You will notice that some of these commands can only be executed in root. I DO NOT have either of these files in root. However, I do have a script setup file that I can call when I am in a root terminal. I call it set_tr and place it in the /bin dir. -Or- you can leave it in your own /home/bin dir and use the full path name when executing it. Your choice.
NotePara:Note: For those of you who don't know, the '&' at the end of one of
these lines completes the command. If it opens another terminal -or- is performing a long operation you don't
really want the terminal window that started it tied up. So, it executes the command and then releases the
terminal window that started it for more operations.
One other item. There are dots in front of some of the names -and/or- at the start of the command line. If you
try something and it doesn't work... check to see if a dot was needed.
#!/bin/bash . /home/username/.function . /home/username/.alias
# ****************************************************************************
# ****************************************************************************
# trivial alias definitions
# ****************************************************************************
# ****************************************************************************
#
# ****************************************************************************
# Start and Stop for Samba. Must be in root.
# smbd - file and print services to SMB (Server Message Block) clients
# nmbd - NetBIOS nameserving and browsing support
# ****************************************************************************
alias stopnmb='/etc/rc.d/nmb stop'
alias startnmb='/etc/rc.d/nmb start'
alias stopsmb='/etc/rc.d/smb stop'
alias startsmb='/etc/rc.d/smb start'
#
# ****************************************************************************
# Start and Stop for MySQL. Must be in root.
# ****************************************************************************
#
alias startmysql='mysqld_safe --user=mysql &'
alias stopmysql='mysqladmin shutdown'
#
# ****************************************************************************
# Little cheats of my own. Ones that begin with '_' are calls to items in
# my .function file.
# ****************************************************************************
#
alias copy='cp'
alias rm='rm -i'
alias d='less'
alias md='mkdir'
alias cls='clear'
alias tl='_set_title'
This can be a problem on some systems. See Below for more info.
alias del='rm -i'
alias net='/sbin/ifconfig'
alias disp='_show_disp'
alias tome='cd /home/ctaylor'
alias totr='cd /home/ctaylor'
alias tosrc='cd /home/ctaylor/src'
alias toscr='cd /home/ctaylor/scripts'
alias todocs='cd /home/ctaylor/Documents'
alias pubht='cd /home/ctaylor/public_html'
alias find_file='find . -print | xargs grep $1 2> /dev/null'
alias xscrn='xscreensaver-demo &'
# ****************************************************************************
# Fire up timidity and play some music.
# ****************************************************************************
#
alias playmusic='/usr/bin/timidity -iatv &'
# *****************************************************************************
#
# Make ls, list defaults command,
# F - notes files types using
# / (slash) it is a directory
# * (asterisk) if the file can be executed
# = (equal sign) if the file is a socket
# | (pipe) sign if the file is a FIFO
# @ for a symbolic link
# C - Sorts output vertically (confuses things).
# a - Lists all files including those prefixed with "." (dot).
# A - List all . prefixed files except "." and "..".
# *****************************************************************************
alias lsa='ls -FA' # include hidden files
alias ldir='_ldir' # only list the directories
alias ldm='ls -ltF' # list by modification time
alias ldh='ls -ltFh' # list by modification time - sizes human format
alias ldsi='ls -ltF --si' # list by modification time - 1000 not 1024
alias ldma='ls -ltFA' # list by modification time - include hidden
alias ldr='ls -ltrFA' # list by modification time - reverse order
alias ldmm='_ldmm' # pageable listing
alias lsd='ls -F' # short form - no hidden
# *****************************************************************************
# Report the PATH environment variable line by line.
# *****************************************************************************
alias path='echo $PATH | tr ":" "\12" | more'
alias mounted='_mounted'
# *****************************************************************************
# TR Specials
# *****************************************************************************
# Clean up - remove temp and backup files
alias rmb='rm -f *~;rm -f .*~;rm -f *.bak;rm -f *.bkp;rm -f .*.bak;rm -f \#*\#;rm -f .\#*'
# List all temp and back up files.
alias lmb='ls -lt *~;ls -lt .*~;ls -lt *.bak;ls -lt *.bkp;ls -lt .*.bak;ls -lt \#*\#;ls -lt .\#*'
#
alias ren='mv $1 $2' # Rename a file
alias rd='rm -fr $1' # Remove dir
alias pem='_pem' # Emacs
alias pem2='_pem2' # Emacs
alias pe='_pe' # Call to Xwpe Editor
alias xpe='_pe' # Call to Xwpe editpr
alias ne='_ne' # Call to Nedit
alias trmt='_trmt' # Experimentation ...
alias blu='_blu' # BlueFish HTML editor
# *****************************************************************************
# Fire off terminal widows of various colors.... just because!!
alias trmp1='xterm -geometry 100x35+110+50 -bg LightSteelBlue3 -fg Black -font 8x13 -rightbar -T BlueWin &'
alias trmp2='xterm -geometry 100x35+80+130 -bg RoyalBlue4 -fg White -font 8x13 -rightbar -T RoyalBlue &'
alias trmp3='xterm -geometry 100x35+80+130 -bg Salmon -fg Black -font 8x13 -rightbar -T Miscellaneous &'
alias trmp4='xterm -geometry 80x25+90+230 -bg NavajoWhite -fg Black -font 8x13 -rightbar -T For_ftping &'
#
# Calls to functions in the function file
alias trmp5='_trm5'
alias trmp6='_trm6'
alias trmp7='_trm7'
alias trmp8='_trm8'
alias trmp9='_trm9'
alias trmp10='_trm10'
alias trmp11='_trm11'
alias trmp12='_trm12'
alias trmp13='_trm13'
alias trmp14='_trm14'
alias trmp15='_trm15'
alias trmp16='_trm16'
alias trmp17='_trm17'
alias trmp18='_trm18'
alias trmp19='_trm19'
alias trmp20='_trm20'
#
# *****************************************************************************
# Open for two different root windows. Used when I need to make some root changes.
# *****************************************************************************
alias goroot='xhost + local:root; xterm -geometry 100x35+130+90 -bg Red3 -fg White -font 8x13 -rightbar -T InRoot -e su &'
alias goroot2='xhost + local:root; xterm -geometry 100x35+130+90 -bg firebrick -fg White -font 8x13 -rightbar -T InRoot -e su &'
# *****************************************************************************
# Don't remember ... but it was something important. (grin)
# *****************************************************************************
alias trmvnc='xterm -geometry 45x10+90+230 -bg Cyan4 -fg White -font 8x13 -rightbar -T VNCViewer &'
#
# *****************************************************************************
# This one will open a window into my Oracle user so that I can play with Oracle.
# *****************************************************************************
alias ora8='xhost + local:root; xterm -geometry 100x35+90+230 -bg RosyBrown -fg White -font 8x13 -rightbar -T Oracle8i -e su - oracle'
In some peoples eyes, even mine, some of these functions are kinda silly. I started to consolidate some of them and got side tracked (which happens to me al lot). Anyway I wanted, and still do want, to consolidate some of the differnt terminal funtions. Just more or less have one function with args passed that will set it up differently. In the beginning I took the easy way out and haven't got around to changing it yet. If I do, it will be here. Otherwise you can play with the ideas yourself ... and learn.
# ***************************************************************************** # ***************************************************************************** # Function definitions. # ***************************************************************************** # ***************************************************************************** # ***************************************************************************** # Display of the devices mounted in a 'prettier' format. # ***************************************************************************** function _mounted { echo echo " Device/FS MountPnt FStype Options"; echo "========================================================================="; mount | gawk '$1 {printf("%-25s %s %-15s %s %-10s %s\n",$1,$2,$3,$4,$5,$6); }'; echo } # ***************************************************************************** # Paged ldm # ***************************************************************************** function _ldmm { DIR_NAME=$* ls -ltFA $DIR_NAME | more } # ***************************************************************************** # Show characteristics of dir NOT contents. # ***************************************************************************** function _ldir { DIR_NAME=$* ls -Fld $DIR_NAME | grep / | sort -k 6,7 -k 8,8 } # ***************************************************************************** # Shortcut?? to BlueFish # ***************************************************************************** function _blu { FILE_NAME=$* /opt/gnome/bin/bluefish $FILE_NAME & } # ***************************************************************************** # Shortcut to xwpe # ***************************************************************************** function _pe { FILE_NAME=$* \xwpe $FILE_NAME & } # ***************************************************************************** # Shortcut to nedit # ***************************************************************************** function _ne { FILE_NAME=$* /usr/X11R6/bin/nedit $FILE_NAME & } # ***************************************************************************** # Make emacs, Blue Version, always run in the back ground. # ***************************************************************************** function _pem { FILE_NAME=$* if [ -z $DISPLAY ]; then echo "DISPLAY is not setup." else \emacs -u ctaylor -geometry 95x53+10+20 -cr Red -ms White -font 8x13bold -fg blanchedalmond -bg SlateGrey $FILE_NAME & fi } # ***************************************************************************** # Make emacs, Grey Version, always run in the back ground. # ***************************************************************************** function _pem2 { FILE_NAME=$* if [ -z $DISPLAY ]; then echo "DISPLAY is not setup." else \emacs -u ctaylor -geometry 95x53+10+20 -font 8x13bold -cr Red -fg AntiqueWhite -bg Turquoise4 -ms NavajoWhite $FILE_NAME & fi } # ***************************************************************************** # Show your IP # ***************************************************************************** function _show_disp { echo "" /sbin/ifconfig | fgrep "inet addr" echo "" }
Top # ***************************************************************************** # This function sets the Termina window title string. Now in SuSE, and possibly # some others, they set up the title for you... whether you wanted them to or # not. This is done in /etc/bash.bashrc I changed mine so I could set my own # titles. # ***************************************************************************** function _set_title { if [ .$TERM = .xterm ]; then if [ $# = 0 ]; then MACHINE_CODE=`hostname -s | cut -c3,5-6` USER=`whoami` TITLE="$MACHINE_CODE $USER" else TITLE=$1 fi xtermset -T $TITLE fi } # ***************************************************************************** # This function will open a terminal window ... experimental # ***************************************************************************** function _trmt { if [ $# = 0 ]; then echo "Please include background color and Title" else TITLE=$2 BG=$1 xterm -geometry 80x25+90+230 -bg $BG -fg White -font 8x13 -T $TITLE & fi } # From here down I probably wasted a lot of space. But I got a lot of differently # colored windows. # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm5 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg LemonChiffon -fg Black -font 8x13 -rightbar -T LemonChiffon & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg LemonChiffon -fg Black -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm6 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg SlateGrey -fg White -font 8x13 -rightbar -T SlateGrey & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg SlateGrey -fg White -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm7 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg PaleTurquoise3 -fg MidnightBlue -font 8x13 -rightbar -T PaleTurquoise3 & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg PaleTurquoise3 -fg MidnightBlue -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm8 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg DarkSeaGreen -fg DarkGreen4 -font 8x13 -rightbar -T DarkSeaGreen & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg DarkSeaGreen -fg DarkGreen4 -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm9 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg aquamarine -fg DarkGreen4 -font 8x13 -rightbar -T Aquamarine & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg aquamarine -fg DarkGreen4 -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm10 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg MediumAquamarine -fg DarkGreen4 -font 8x13 -rightbar -T MediumAquamarine & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg MediumAquamarine -fg DarkGreen4 -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm11 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg Cyan4 -fg White -font 8x13 -rightbar -T Cyan4 & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg Cyan4 -fg White -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm12 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg Cyan3 -fg DarkGreen4 -font 8x13 -rightbar -T Cyan3 & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg Cyan3 -fg DarkGreen4 -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm13 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg RosyBrown -fg Black -font 8x13 -rightbar -T RosyBrown & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg RosyBrown -fg Black -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm14 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg RosyBrown2 -fg Black -font 8x13 -rightbar -T RosyBrown2 & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg RosyBrown2 -fg Black -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm15 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg SaddleBrown -fg White -font 8x13 -rightbar -T SaddleBrown & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg SaddleBrown -fg White -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm16 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg sienna -fg White -font 8x13 -rightbar -T Sienna & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg sienna -fg White -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm17 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg SandyBrown -fg Brown4 -font 8x13 -rightbar -T SandyBrown & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg SandyBrown -fg Brown4 -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm18 { if [ $# = 0 ]; then xterm -geometry 100x35+90+10 -bg firebrick -fg White -font 8x13 -rightbar -T FireBrick & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg firebrick -fg White -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm19 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg maroon -fg White -font 8x13 -rightbar -T Maroon & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg maroon -fg White -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trm20 { if [ $# = 0 ]; then xterm -geometry 80x25+90+230 -bg SteelBlue4 -fg White -font 8x13 -rightbar -T SteelBlue4 & else if [ $# = 2 ]; then TITLE=$2 else TITLE=$1 fi xterm -geometry 80x25+90+230 -bg SteelBlue4 -fg White -font 8x13 -rightbar -T $TITLE -e telnet $1 & fi } # # # ***************************************************************************** # This function will open a terminal window # ***************************************************************************** function _trmxx { if [ $# = 0 ]; then v1=1 else v1=$1 fi }