does it not need to be `funtion today ()`?
does it not need to be `funtion today ()`?
ok, i put in the altered code that was suggested earlier by mssever and it worked, apparently somehow my mouse wheel pastes when it clicks so i had a bunch of random stuff throughout my .bashrc file. i have it to where it will work now, but there is still something that pops up when i open the terminal
bash: [: /etc/bash_complittle: binary operator expected
i dont know if it is important or not, but it didnt use to show up so i thought i would throw it out there to you guys. thanks again for all the help
Well, I have some tricks here in my .bash_aliases. Hope someone can find them useful.
Code:alias +alias='echo alias $1 >> ~/.bash_aliases' alias aliases='cat -n ~/.bash_aliases' alias bash-reload='. ~/.bashrc' alias bash-aliases='gedit ~/.bash_aliases' alias apti='sudo aptitude install' alias aptr='sudo aptitude remove' alias apts='aptitude search' alias update='sudo aptitude update' alias upgrade='sudo aptitude upgrade' alias dist-upgrade='sudo aptitude dist-upgrade' alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' alias xx='exit' alias cc='clear' alias ccd='cd ~/ && clear' alias mp3='cd ~/musik' alias fcc='/opt/firstclass/fcc &' alias bt='btdownloadgui &' alias irc='Eterm --trans -x --shade=0 --scrollbar=0 --buttonbar=0 --geometry=75x30+850+750 -e irssi -c chat.freenode.net --nick=nahoj' alias forum='firefox http://ubuntu-se.org/forum &' alias mail='firefox http://gmail.com &' alias google='firefox http://google.com/linux &' alias anthony='mocp -c && mocp -a -p ~/musik/anthony_and_the_johnsons/' alias imabird='mocp -c && mocp -a -p ~/musik/anthony_and_the_johnsons/i_am_a_bird_now/' alias rhcp='mocp -c && mocp -a -p ~/musik/red_hot_chili_peppers/' alias soad='mocp -c && mocp -a -p ~/musik/system_of_a_down/' alias madonna='mocp -c && mocp -a -p ~/musik/madonna/' alias arctic='mocp -c && mocp -a -p ~/musik/arctic_monkeys/' alias muse='mocp -c && mocp -a -p ~/musik/muse/' alias tot='mocp -c && mocp -a -p ~/musik/theatre_of_tradgedy/' alias killers='mocp -c && mocp -a -p ~/musik/the_killers/' alias queen='mocp -c && mocp -a -p ~/musik/queen/' alias creed='mocp -c && mocp -a -p ~/musik/Creed/' alias hellacopters='mocp -c && mocp -a -p ~/musik/the_hellacopters/' alias u2='mocp -c && mocp -a -p ~/musik/U2/' alias wolfmother='mocp -c && mocp -a -p ~/musik/wolfmother/' alias forw='mocp -f' alias prev='mocp -r' alias sources='gksudo gedit /etc/apt/sources.list &'
One trick I find very useful is setting cdpath. Basically if there are folders that you access regularly, you can easily access those directories without typing the entire path.
For example: I keep my music on my external hard drive. If I wanted to access the folder 'The roots', ordinarily the path would be :
To make it easy for me, I set my external hard drive in the cdpath in my .bash_profile and .bashrc :Code:cd /media/usbdisk/Music/The_roots
So when you type cd <some folder>, it first checks the current directory (.) for <some folder>, then my home directory (~) , then finally the music directory on my external hard drive (/media/usbdisk/Music).Code:CDPATH=".:~:/media/usbdisk/Music"
As a result I can directly access my 'The_roots' folder anywhere by typing:
Some people like to use aliases to define frequent folders. But I like this method more because I don't have to update the alias list if I add new folders. Also always add the "." in the beginning of the cdpath or else it won't check the present directory for the folder.Code:cd The_roots
For more info and tips:
http://www.caliban.org/bash/
Here is my "short list"
Propmt:
command history:For users add the color of your choice:
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$' #Green
PS1='\[\033[01;34m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$' #Blue
For root add this to /root/.bashrc
PS1='\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$' #Red
Now if you sudo su you will have a red prompt to remind you that you are ROOT.
colorize grep:alias hist='history | grep $1' #Requires one input
Now: hist <command> will return something like this
502 <command>
Just type !502 at the prompt and the command will be repeated.
Archive:alias g="grep --color=always"
alias gi="grep -i --color=always"
Note:grep -i = ignore case
Mount usb:# Extract files from any archive
# Usage: ex <archive_name>
ex () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# Thanks to rezza at Arch Linux
No clobber:alias usb='sudo mount LABEL=USB /mnt/USB/ -o uid=1000,gid=100,umask=007'
You can now mount the device, with or without an entry in fstab, by typing:
usb
Note: To determine the label of a device, with the device connected to the usb port
ls /dev/disk/by-label
set -o noclobber #Prevents redirection of output from overwriting an existing file
Use >> rather then > to re-direct
> overwrites the file.
>> Adds to the end of the file.
Note: To override use >|
ie echo new_txt >| <dest_file>
There are two mistakes one can make along the road to truth...not going all the way, and not starting.
--Prince Gautama Siddharta
#ubuntuforums web interface
I have a good 34 aliases defined (ZSH):The ones that start with ":" are global aliases, which means I can use them anywhere in a command. For example, to list the files in the zsh package, sort alphabetically, and view in less:Code:..='cd ..' ...='cd ../..' ....='cd ../../..' :en='2> /dev/null' :g='| grep' :l='| less' :n='&> /dev/null' :sl='| sort | less' :sn='1> /dev/null' apt='sudo aptitude' apti='sudo aptitude install' aptr='sudo aptitude remove' aptu='sudo aptitude update && sudo aptitude upgrade' du='du -h' dv='setxkbmap us dvorak' grep=egrep la='ls -a' ll='ls -l' ls='ls --color=auto' lsa='ls -ld .*' lsbig='ls -lSh *(.) | head' lsd='ls -ld *(-/DN)' lsnew='ls -lrt *(.) | tail' lsold='ls -lrt *(.) | head' lssmall='ls -lSh *(.) | head' mmv='noglob zmv -W' open=gnome-open qw='setxkbmap us' rc='sudo invoke-rc.d' ri='noglob ri' tarbc='tar --bzip2 -cvf' targc='tar -czvf' tarx='tar -xvf' which-command=whenceIf you want me to explain any of these, just ask.Code:dpkg -L zsh :sl
this is a great thread! Maybe someone can help me witht he following, i used to have a little script, aliassed as "vim" that would try to open the file with vim, but if it was readonly use "sudo vim". Unfortunatly i list this script somewhere aling the line and have never been able to find it again.
THX! you made my day!
Keystrokes can be saved by using shortcuts for changing directories back AND supplying an additional argument: the directory to go forth from there.
It is like making a U-turn:
.. [dir] = cd ../[dir]
... [dir] = cd ../../[dir]
.... [dir] = cd ../../../[dir]
..... [dir] = cd ../../../../[dir]
...... [dir] = cd ../../../../../[dir]
....... [dir] = cd ../../../../../../[dir]
........ [dir] = cd ../../../../../../../[dir]
The directory-argument can be TAB-completed!
Include the script underneath in your ~/.bashrc with the command: source cdots.sh
See also:Code:#!/bin/bash # --- cdots.sh ------------------------------------------------------- # Change directory back - 1-7 times - and forth with TAB-completion. # Copyright (C) 2006 Freddy Vulto # Version: 1.0.8 # Usage: ..[.[.[.[.[.[.]]]]]] [dir] # # Arguments: [dir] Directory to go forth - down the directory tree # # Example: $/usr/share> .. local/share/ # .. lo[TAB]/sh[TAB]) # $/usr/local/share> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA # # The latest version of this software can be obtained here: # http://www.fvue.nl/cdots/ CDOTS_DEPTH=7 #--- _cdots() -------------------------------------------------------- # TAB completion for the .. ... .... etc commands # @see cdots() _cdots() { # ':2' = Ignore two dots at pos 0, $'\012' = newline (\n) local dots=${COMP_WORDS[COMP_CWORD-1]:2} IFS=$'\012' i j k=0 local dir=${dots//./..\/}../ # Replace . with ../ for j in $(compgen -d -- "$dir${COMP_WORDS[COMP_CWORD]}"); do # If j not dir in current dir, append extra slash '/' # NOTE: If j is also dir in current dir, 'complete -o #+ filenames' automatically appends slash '/' [ ! -d ${j#$dir} ] && j="$j/" COMPREPLY[k++]="${j#$dir}" done } # _cdots() #--- cdots() --------------------------------------------------------- # Change directory to specified directories back, and forth # @param $1 string Directory back # @param $2 string Directory forth # @see _cdots() for TAB-completion function cdots() { cd "$1$2" } # cdots() # Define aliases .. ... .... etc # NOTE: Functions are not defined directly as .. ... .... etc, # because these are not valid identifiers under `POSIX' cdotsAlias=.; cdotsAliases=; cdotsDir= for ((i = 1; i <= $CDOTS_DEPTH; i++)); do cdotsAlias=$cdotsAlias.; cdotsDir=$cdotsDir../ alias $cdotsAlias="cdots $cdotsDir" cdotsAliases="$cdotsAliases $cdotsAlias" done # Set completion of aliases .. ... .... etc to _cdots() # -o filenames: Escapes whitespace complete -o filenames -o nospace -F _cdots $cdotsAliases unset -v CDOTS_DEPTH cdotsAlias cdotsAliases cdotsDir i
http://www.fvue.nl/cdots/
Freddy Vulto
Bookmarks