1. Este site usa cookies. Ao continuar a usar este site está a concordar com o nosso uso de cookies. Saber Mais.

Como vamos de 'alias'?

Discussão em 'Novidades GNU/Linux & *nix World' iniciada por slack_guy, 10 de Novembro de 2007. (Respostas: 58; Visualizações: 6957)

  1. slack_guy

    slack_guy Power Member

    Seria interessante trocarmos 'alias' para vermos que coisas novas há por aí.

    Ora cá vão os meus (convenientemente editados :-) )
    Código:
    [[email protected] ~] grep alias .zshrc
    alias DEV_BOX='ssh -Y -p XXXX 111.222.333.444'
    alias PROD_BOX='ssh -Y -p XXXX 111.222.333.444'
    alias montaPROD_BOX='sshfs -o workaround=rename -p XXXX 111.222.333.444:/ /home/me/PROD_BOX'
    alias desmontaPROD_BOX='fusermount -u /home/me/PROD_BOX'
    alias montanokia='obexfs -b00:0E:ED:B5:73:15 -B 11 /home/me/myNokia'
    alias desmontanokia='fusermount -u /home/me/myNokia'
    alias FAR_HOST='ssh -Y -l ME -p XXXX `lynx --dump http://www.FAR_HOST.com/ip`'
    alias rm='rm -i'
    alias ..='cd ..'
    alias df='df -h'
    alias grep='egrep --color=auto'
    alias agora='date "+%A, %d %B, %G%t%H:%M"'
    alias ff='find . -name $*'
    alias rootme='su -s /bin/zsh - root'
    alias untar='tar zxvf'
    alias gvim='/usr/bin/gvim -geom 139x56'
    alias musica='mocp -T transparent-background'
    alias pc='perl -ple"\$_=eval"'
    alias ripacd='cdparanoia -d /dev/hdc -B'
    alias gravacd='cdrecord dev=/dev/hdd -v -dao *.wav'
    alias radio='streamripper http://207.200.96.232:8002 -r'
    alias tudoparamp3='for i in *; lame $i'
    alias cl='clear'
    alias cls=cl
    alias l='ls --color -F -b -T 0 -h'
    alias sl=l
    alias clls='clear;l'
    alias killthefox='killall firefox-bin'
    alias p='pwd'
    alias m='mutt'
    alias goo='google'
    alias v='vim'
    alias r='rox'
    alias cm=check_mail
    
    Para os curiosos, a função check_mail é a seguinte (também no .zshrc):
    Código:
    function check_mail() {
    
        /usr/bin/perl -MMail::IMAPTalk -le \
        '$imap=Mail::IMAPTalk->new(
            Server => q|REMOTE_BOX|,
            Username => q|myUsername|,
            Password => q|myPassword|,
            Uid => 1
         );
         $imap->select(q|INBOX|);
         print scalar @{$imap->search(q|not|,q|seen|)}, " MAILS!";'
    
    }
    
    
     
    Última edição: 10 de Novembro de 2007
  2. madskaddie

    madskaddie Power Member

    Esta é a melhor thread ;) infelizmente os meus alias foram com o disco que se avariou :( mas vejo ai muitos deles! :)

    mas podes juntar:
    Código:
    
    alias ll="ls -l"
    alias emacsnw="emacs -nw"
    alias x="exit"
    
    alias new="pine -i" (nalgumas maquinas)
    
    Certamente teria mais, mas estes mais alguns da tua lista, fazem ja os que me recordo
     
  3. slack_guy

    slack_guy Power Member

    ah! se calhar não tinhas um 'alias' para isto:
    Código:
    alias backmeup='rsync -avz --delete  /home/me/ /external_disk/backups/'
    
    :-)
     
  4. APLinhares

    APLinhares OpenSource Moderator
    Staff Member

    Aproveito para partilhar este. talvez 1 pouco exagerado :D
    Código:
    #######################################################
    # Dave Crouse's .bashrc file
    # www.bashscripts.org
    # www.usalug.org
    #
    # Last Modified 04-08-2006
    # Running on OpenSUSE 10
    #######################################################
    
    
    # EXPORTS
    #######################################################
    
    PATH=$PATH:/usr/lib/festival/ ;export PATH
    export PS1="[\[\033[1;34m\w\[\033[0m]\n[\t \u]$ "
    export EDITOR=/usr/bin/pico
    export HISTFILESIZE=3000 # the bash history should save 3000 commands
    export HISTCONTROL=ignoredups #don't put duplicate lines in the history.
    alias hist='history | grep $1' #Requires one input
    
    # Define a few Color's
    BLACK='\e[0;30m'
    BLUE='\e[0;34m'
    GREEN='\e[0;32m'
    CYAN='\e[0;36m'
    RED='\e[0;31m'
    PURPLE='\e[0;35m'
    BROWN='\e[0;33m'
    LIGHTGRAY='\e[0;37m'
    DARKGRAY='\e[1;30m'
    LIGHTBLUE='\e[1;34m'
    LIGHTGREEN='\e[1;32m'
    LIGHTCYAN='\e[1;36m'
    LIGHTRED='\e[1;31m'
    LIGHTPURPLE='\e[1;35m'
    YELLOW='\e[1;33m'
    WHITE='\e[1;37m'
    NC='\e[0m'              # No Color
    # Sample Command using color: echo -e "${CYAN}This is BASH
    ${RED}${BASH_VERSION%.*}${CYAN} - DISPLAY on ${RED}$DISPLAY${NC}\n"
    
    
    # SOURCED ALIAS'S AND SCRIPTS
    #######################################################
    
    ### Begin insertion of bbips alias's ###
    source ~/.bbips/commandline/bbipsbashrc
    ### END bbips alias's ###
    
    # Source global definitions
    if [ -f /etc/bashrc ]; then
        . /etc/bashrc
    fi
    
    # enable programmable completion features
    if [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
    fi
    
    
    # ALIAS'S OF ALL TYPES SHAPES AND FORMS ;)
    #######################################################
    
    # Alias's to local workstations
    alias tom='ssh 192.168.2.102 -l root'
    alias jason='ssh 192.168.2.103 -l root'
    alias randy='ssh 192.168.2.104 -l root'
    alias bob='ssh 192.168.2.105 -l root'
    alias don='ssh 192.168.2.106 -l root'
    alias counter='ssh 192.168.2.107 -l root'
    
    # ALIAS TO REMOTE SERVERS
    alias ANYNAMEHERE='ssh YOURWEBSITE.com -l USERNAME -p PORTNUMBERHERE'
    # My server info removed from above for obvious reasons ;)
    
    # Alias's to TN5250 programs. AS400 access commands.
    alias d1='xt5250 env.TERM = IBM-3477-FC env.DEVNAME=D1 192.168.2.5 &'
    alias d2='xt5250 env.TERM = IBM-3477-FC env.DEVNAME=D2 192.168.2.5 &'
    alias tn5250j='nohup java -jar /home/crouse/tn5250j/lib/tn5250j.jar
    2>>error.log &'
    
    # Alias's to some of my BashScripts
    alias bics='sh /home/crouse/scripts/bics/bics.sh'
    alias backup='sh /home/crouse/scripts/usalugbackup.sh'
    alias calc='sh /home/crouse/scripts/bashcalc.sh'
    alias makepdf='sh /home/crouse/scripts/makepdf.sh'
    alias phonebook='sh /home/crouse/scripts/PHONEBOOK/baps.sh'
    alias pb='sh /home/crouse/scripts/PHONEBOOK/baps.sh'
    alias ppe='/home/crouse/scripts/passphraseencryption.sh'
    alias scripts='cd /home/crouse/scripts'
    
    # Alias's to control hardware
    alias cdo='eject /dev/cdrecorder'
    alias cdc='eject -t /dev/cdrecorder'
    alias dvdo='eject /dev/dvd'
    alias dvdc='eject -t /dev/dvd'
    alias scan='scanimage -L'
    alias playw='for i in *.wav; do play $i; done'
    alias playo='for i in *.ogg; do play $i; done'
    alias playm='for i in *.mp3; do play $i; done'
    alias copydisk='dd if=/dev/dvd of=/dev/cdrecorder' # Copies bit by bit
    from dvd to cdrecorder drives.
    alias dvdrip='vobcopy -i /dev/dvd/ -o ~/DVDs/ -l'
    
    # Alias's to modified commands
    alias ps='ps auxf'
    alias home='cd ~'
    alias pg='ps aux | grep'  #requires an argument
    alias un='tar -zxvf'
    alias mountedinfo='df -hT'
    alias ping='ping -c 10'
    alias openports='netstat -nape --inet'
    alias ns='netstat -alnp --protocol=inet | grep -v CLOSE_WAIT | cut
    -c-6,21-94 | tail +2'
    alias du1='du -h --max-depth=1'
    alias da='date "+%Y-%m-%d %A    %T %Z"'
    alias ebrc='pico ~/.bashrc'
    
    # Alias to multiple ls commands
    alias la='ls -Al'               # show hidden files
    alias ls='ls -aF --color=always' # add colors and file type extensions
    alias lx='ls -lXB'              # sort by extension
    alias lk='ls -lSr'              # sort by size
    alias lc='ls -lcr'      # sort by change time
    alias lu='ls -lur'      # sort by access time
    alias lr='ls -lR'               # recursive ls
    alias lt='ls -ltr'              # sort by date
    alias lm='ls -al |more'         # pipe through 'more'
    
    # Alias chmod commands
    alias mx='chmod a+x'
    alias 000='chmod 000'
    alias 644='chmod 644'
    alias 755='chmod 755'
    
    # Alias Shortcuts to graphical programs.
    alias kwrite='kwrite 2>/dev/null &'
    alias firefox='firefox 2>/dev/null &'
    alias gaim='gaim 2>/dev/null &'
    alias kate='kate 2>/dev/null &'
    alias suk='kdesu konqueror 2>/dev/null &'
    
    # Alias xterm and aterm
    alias term='xterm -bg AntiqueWhite -fg Black &'
    alias termb='xterm -bg AntiqueWhite -fg NavyBlue &'
    alias termg='xterm -bg AntiqueWhite -fg OliveDrab &'
    alias termr='xterm -bg AntiqueWhite -fg DarkRed &'
    alias aterm='aterm -ls -fg gray -bg black'
    alias xtop='xterm -fn 6x13 -bg LightSlateGray -fg black -e top &'
    alias xsu='xterm -fn 7x14 -bg DarkOrange4 -fg white -e su &'
    
    # Alias for lynx web browser
    alias bbc='lynx -term=vt100 http://news.bbc.co.uk/text_only.stm'
    alias nytimes='lynx -term=vt100 http://nytimes.com'
    alias dmregister='lynx -term=vt100 http://desmoinesregister.com'
    
    
    # SOME OF MY UNUSED ALIAS's
    #######################################################
    
    # alias d=`echo "Good Morning Dave. today's date is" | festival --tts;
    date +'%A %B %e' | festival --tts`
    # alias shrink84='/home/crouse/shrink84/shrink84.sh'
    # alias tl='tail -f /var/log/apache/access.log'
    # alias te='tail -f /var/log/apache/error.log'
    
    
    # SPECIAL FUNCTIONS
    #######################################################
    
    netinfo ()
    {
    echo "--------------- Network Information ---------------"
    /sbin/ifconfig | awk /'inet addr/ {print $2}'
    echo ""
    /sbin/ifconfig | awk /'Bcast/ {print $3}'
    echo ""
    /sbin/ifconfig | awk /'inet addr/ {print $4}'
    
    # /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
    echo "---------------------------------------------------"
    }
    
    spin ()
    {
    echo -ne "${RED}-"
    echo -ne "${WHITE}\b|"
    echo -ne "${BLUE}\bx"
    sleep .02
    echo -ne "${RED}\b+${NC}"
    }
    
    scpsend ()
    {
    scp -P PORTNUMBERHERE "$@"
    [email protected]:/var/www/html/pathtodirectoryonremoteserver/;
    }
    
    
    # NOTES
    #######################################################
    
    # To temporarily bypass an alias, we preceed the command with a \
    # EG:  the ls command is aliased, but to use the normal ls command you would
    # type \ls
    
    # mount -o loop /home/crouse/NAMEOFISO.iso /home/crouse/ISOMOUNTDIR/
    # umount /home/crouse/NAMEOFISO.iso
    # Both commands done as root only.
    
    
    # WELCOME SCREEN
    #######################################################
    
    clear
    for i in `seq 1 15` ; do spin; done ;echo -ne "${WHITE} USA Linux Users
    Group ${NC}"; for i in `seq 1 15` ; do spin; done ;echo "";
    echo -e ${LIGHTBLUE}`cat /etc/SUSE-release` ;
    echo -e "Kernel Information: " `uname -smr`;
    echo -e ${LIGHTBLUE}`bash --version`;echo ""
    echo -ne "Hello $USER today is "; date
    echo -e "${WHITE}"; cal ; echo "";
    echo -ne "${CYAN}";netinfo;
    mountedinfo ; echo ""
    echo -ne "${LIGHTBLUE}Uptime for this computer is ";uptime | awk /'up/
    {print $3,$4}'
    for i in `seq 1 15` ; do spin; done ;echo -ne "${WHITE} http://usalug.org
    ${NC}"; for i in `seq 1 15` ; do spin; done ;echo ""; echo ""; echo ""
    E umas funções como consulta de tempo, bolsa/acções, e tradutor ?
    Código:
    # <--------- Cool Functions by Crouse-------->
    # Cool Functions for your .bashrc file.
    
    # Weather by us zip code - Can be called two ways # weather 50315 # weather "Des Moines"
    weather ()
    {
    declare -a WEATHERARRAY
    WEATHERARRAY=( `lynx -dump "http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=weather+${1}&btnG=Search" | grep -A 5 -m 1 "Weather for"`)
    echo ${WEATHERARRAY[@]}
    }
    
    # Stock prices - can be called two ways. # stock novl  (this shows stock pricing)  #stock "novell"  (this way shows stock symbol for novell)
    stock ()
    {
    stockname=`lynx -dump http://finance.yahoo.com/q?s=${1} | grep -i ":${1})" | sed -e 's/Delayed.*$//'`
    stockadvise="${stockname} - delayed quote."
    declare -a STOCKINFO
    STOCKINFO=(` lynx -dump http://finance.yahoo.com/q?s=${1} | egrep -i "Last Trade:|Change:|52wk Range:"`)
    stockdata=`echo ${STOCKINFO[@]}`
    	if [[ ${#stockname} != 0 ]] ;then
    		echo "${stockadvise}"
    		echo "${stockdata}"
    			else
    			stockname2=${1}
    			lookupsymbol=`lynx -dump -nolist http://finance.yahoo.com/lookup?s="${1}" | grep -A 1 -m 1 "Portfolio" | grep -v "Portfolio" | sed 's/\(.*\)Add/\1 /'`
    				if [[ ${#lookupsymbol} != 0 ]] ;then
    				echo "${lookupsymbol}"
    					else
    					echo "Sorry $USER, I can not find ${1}."
    				fi
    	fi
    }
    
    #Translate a Word  - USAGE: translate house spanish  # See dictionary.com for available languages (there are many).
    translate ()
    {
    TRANSLATED=`lynx -dump "http://dictionary.reference.com/browse/${1}" | grep -i -m 1 -w "${2}:" | sed 's/^[ \t]*//;s/[ \t]*$//'`
    if [[ ${#TRANSLATED} != 0 ]] ;then
    	echo "\"${1}\" in ${TRANSLATED}"
    	else
    	echo "Sorry, I can not translate \"${1}\" to ${2}"
    fi
    }
    
    # Define a word - USAGE: define dog
    define ()
    {
    lynx -dump "http://www.google.com/search?hl=en&q=define%3A+${1}&btnG=Google+Search" | grep -m 3 -w "*"  | sed 's/;/ -/g' | cut -d- -f1 > /tmp/templookup.txt
    			if [[ -s  /tmp/templookup.txt ]] ;then	
    				until ! read response
    					do
    					echo "${response}"
    					done < /tmp/templookup.txt
    				else
    					echo "Sorry $USER, I can't find the term \"${1} \""				
    			fi	
    rm -f /tmp/templookup.txt
    }Ou entao uma calculadora.
    Código:
    #!/bin/bash
    
    #######################################################
    #     Bash CALCulator 2
    #######################################################
    #
    #
    #    FILE: bashcalc2.sh
    # VERSION: 1.1
    #    DATE: 06-19-2006
    #
    #  AUTHOR: Crouse - Please visit bashscripts.org and usalug.org
    #
    #
    ########################################################
    
    header ()
    {
    clear; echo "Bash Calculator - Enter a calculation and hit enter";
    echo "---------------------------------------------------";
    }
    
    calc ()
    {
    header
    while true
    do read -p "" bashcalc;
           if [ "$bashcalc" = "quit" ]
             then
               exit
           fi
    
           if [ "$bashcalc" = "clear" ]
            then
              calc
           fi
    
           if [ "$bashcalc" = "help" ]
            then
              clear
              echo "Options include:"
              echo " help - This help file"
              echo " clear - Clears the screen"
              echo " quit - Quits the program"
              echo " "
              read -p  "Hit any key to continue" temp;
              calc
           fi
    
      echo "scale=4; ${bashcalc}" | bc ;
      echo "---------------------";
    done
    }
    
    # Program run starts here
    calc
    
    exit 0
    
    Sky is the limit :)
     
    Última edição: 10 de Novembro de 2007
  5. esquiso

    esquiso Power Member

    Viver e aprender :D Já me fizeste ganhar o dia com esta descoberta, slack_guy :)
    Comecei há pouco, e já cá moram estes:

     
    Última edição: 11 de Novembro de 2007
  6. uterrorista

    uterrorista Suspenso

    quando reinicio o PC os alias desaparecem.
    onde/como gravo isto permanentemente?
     
  7. Ragnarok

    Ragnarok Folding Member

    Ficheiro /home/user/.bashrc .
     
  8. uterrorista

    uterrorista Suspenso

    ja fiz esse ficheiro.
    coloquei lá por exemplo:
    mas nao funciona qd faço cls na consola

    qual é o problema??
     
  9. slack_guy

    slack_guy Power Member

    Ou
    Código:
    $ source ~/.bashrc
    
    ou abres uma nova consola.
     
  10. uterrorista

    uterrorista Suspenso

    era isso mesmo. Obrigado
     
  11. sem kerer parecer mal!

    uma vez que nao uso linux assim a tanto tempo!

    o que sao os alias? para que servem ?!

    Cumps
     
  12. LnxSlck

    LnxSlck Power Member

    Isso e alias é fixe, mas depois uma pessoa fica tão habituada que quando vamos para uma máquina sem isso, ficamos às aranhas :p
     
  13. slack_guy

    slack_guy Power Member

    É bem verdade!!

    Por causa do Vim, sempre que escrevo (fora do Vim) faço [ESCAPE]:w ... hábitos :-)
     
  14. PrOdG

    PrOdG Power Member

    Same here. E o right click dos *box ? ;)
     
  15. slack_guy

    slack_guy Power Member

    right click dos quê??

    BTW, não uso com frequência o 'right click'... é que como não tenho rato (tenho uma 'caneta' da wacom) não me dá muito jeito fazer esse 'click'. PanDeleirices minhas :-)
     
  16. PrOdG

    PrOdG Power Member

    *box = fluxbox, openbox, blackbox, ...
    Right click é o bind para o menu desses WM.

    Não percebi se estavas a ser irónico ou se não sabias mesmo :P
     
  17. slack_guy

    slack_guy Power Member

    ah! como não uso disso, nem me passou pela cabeça :-) Aqui é só FVWM, e só funciona o left click.
     
  18. PrOdG

    PrOdG Power Member

    Vai dar ao mesmo, nos primeiros 2 mins num Gnome ou KDE é andar à nora a tentar perceber o que aconteceu ao menu.. lol

    Anyway, alias aqui são mesmo muito poucos (prefiro não me habituar a comandos locais):
    Código:
    alias ls="ls --color=auto"
    alias ll="ls -l --color=auto"
    alias la="ls -l -a --color=auto"
    alias tv='DISPLAY=":0.1" mplayer -monitoraspect 16:9 -fs'
    Gostei do teu 'killthefox' :P
     
  19. God_Lx

    God_Lx Folding Member

    LOL ProdG ! Isso acontece-me frequentemente... Fico meio perdido à procura do menu...
     

Partilhar esta Página