Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Console / shell tips & tricks
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3 ... 11, 12, 13, 14, 15, 16  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Dralnu
Veteran
Veteran


Joined: 24 May 2006
Posts: 1919

PostPosted: Sun Dec 17, 2006 5:43 am    Post subject: Reply with quote

Its been awhile, so...

Code:
# Coloration for ls && grep...
alias ls="ls -lF --si --color"
alias grep="grep --color"

# Safties. Should keep these...
alias rm="rm -iv"
alias mv="mv -iv"
alias cp="cp -iv"

# Aliases for some security...
alias startx="startx && clear"
alias lock="clear && vlock"

# Shortcut aliases
alias sls="ls -lrSF --color"
alias hg="history | grep"
alias du="sudo du -csx --si"
alias screenshot="/home/user/bin/screenshot_script"

# Portage shortcuts...
alias emerge="sudo emerge"
alias dclean="sudo eclean-dist"
alias rrebuild="sudo revdep-rebuild -- -v"

# Quickly change direcoties
alias ..="cd ../"
alias ...="cd ../../"
alias cdp="cd /home/user/Documents/Scripts/Current\ Project"
alias cdc="cd /home/user/Documents/Source\ Code/"
alias cdv="cd /home/user/Documents/Video/"
alias cdm="cd /home/user/Documents/Music/"

# Media-quickies
alias cmplayer="mplayer -vo ggi -framedrop"
alias mpc-="mpc volume -10" #Temp. Remove when keys are bound
alias mpc+="mpc volume +10" #Temp. Remove when keys are bound

_________________
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
Back to top
View user's profile Send private message
nanafunk
n00b
n00b


Joined: 29 Jun 2005
Posts: 36

PostPosted: Fri Jan 19, 2007 1:07 am    Post subject: Reply with quote

my ~/.bashrc

Code:
##Aliases

#alsamixer
alias a='/usr/bin/alsamixer'
#batteries %
alias b='/usr/local/bin/bat'
#wireless signal
alias c='/bin/awk -F '\''[ .]'\'' '\''/eth1/{print $7}'\'' /proc/net/wireless'
#directory summary
alias ds='/usr/bin/find "$PWD" -mindepth 1 -maxdepth 1 -type d \( -regex '\''^/\(dev\|lost\+found\|mnt\|proc\)'\'' -prune -o -exec /usr/bin/du -sh {} + \)'
#dvd
alias dvd='/usr/bin/vlc /dev/hdc'
#firefox
alias f='/usr/bin/firefox'
#file usage for PWD
alias fu='/usr/bin/find "$PWD" -type f -printf "%-12s%p\n" | /usr/bin/sort -rn -k 1,1 | /usr/bin/less'
#file usage for whole system
alias fua='/usr/bin/find / \( -type d -regex '\''^/\(dev\|lost\+found\|mnt\|proc\)'\'' -prune -o -type f -printf "%-12s%p\n" \) | sort -rn -k1,1 | less '
#top 5 glsas
alias glsa='/usr/bin/curl -s "http://www.gentoo.org/rdf/en/glsa-index.rdf" | /bin/sed -n '\''/<title>GLSA/s/[^(]*\([^)]*): [^ <]*\).*/\1/p'\'' | /usr/bin/head -5'
#grep color
alias grep='/bin/grep --color=auto'
#internal ip
alias iip='/sbin/ifconfig eth1 | /bin/sed -n '\''/inet/s/[^:]*:\([^ ]*\).*/\1/p'\'''
#external ip
alias ip='/usr/bin/curl www.whatismyip.com 2>/dev/null | /bin/sed -n '\''/^<TITLE>/s/.*- \([^<]*\).*/\1/p'\'''
#pager
alias l='/usr/bin/less'
#ls color
alias ls='/usr/bin/ls --color=auto'
#network scan
alias ns='/usr/bin/nmap -sP -oG /dev/stdout -T insane 192.168.0.0/24 |/usr/bin/grep Status:\ Up'
#woo!
alias oc='echo "printf %s\145\170\151\164\012"'
#fed up typing ping all the time :-)
alias p='/bin/ping'
#colourful ruby documentation
alias ri='/usr/bin/ri --format ansi'

#tbh
alias sb='source ~/.bashrc'
alias v='/usr/bin/vim'
alias vb='/usr/bin/vim ~/.bashrc'
alias vx='/usr/bin/vim /etc/X11/xorg.conf'

##Functions

#listing count
lc(){ local i; while read entry; do ((i++)); done < <(printf "%s\n" ./*); echo "$i"; }

#package count -- how many packages installed
pc(){ local i=0; while read; do ((i++)); done < <(printf "%s\n" /var/db/pkg/*/*/); echo "$i"; }

#package listing -- list of packages installed
pl(){ local i; for i in /var/db/pkg/*/*; do i="${i#/*/*/*/}"; echo "${i%-[0-9]*}"; done; }

##prompt

YELLOW=$(tput setaf 3)
RED=$(tput setaf 1)
DEFAULT=$(tput sgr0)

export PS1='\[${YELLOW}\][\[${DEFAULT}\]%\[${YELLOW}\]]\[${DEFAULT}\] '



http://wooledge.org/mywiki/BashFaq#faq37 -- How can I print text in various colors?

Nice way to deal with it, instead of those horrid escape sequences.
Back to top
View user's profile Send private message
Dr. Arbeitslos
Apprentice
Apprentice


Joined: 13 Aug 2005
Posts: 152

PostPosted: Sat Jan 27, 2007 11:35 am    Post subject: Reply with quote

did you ever wanted to know for shure what process is bringing up your disc led now?

Code:
alias blockdump="echo 1 > /proc/sys/vm/block_dump && tail -f /var/log/messages;  echo 0 > /proc/sys/vm/block_dump"


ctrl-c makes everything like before.
Back to top
View user's profile Send private message
adekoba
Tux's lil' helper
Tux's lil' helper


Joined: 06 Oct 2006
Posts: 129

PostPosted: Sat Jan 27, 2007 3:04 pm    Post subject: Reply with quote

does anybody know how to make an alias that cd's normally into the arguments given and then ls's that directory? thanks
_________________
website
Back to top
View user's profile Send private message
dforsyth
n00b
n00b


Joined: 29 Jan 2005
Posts: 26
Location: College Park, Murdaland

PostPosted: Sat Jan 27, 2007 3:17 pm    Post subject: Reply with quote

dark_speedo wrote:
does anybody know how to make an alias that cd's normally into the arguments given and then ls's that directory? thanks


alias cdls="cd $1 && ls"
_________________
O
4~ <-- me, fapping to Palin.
/\ `_
Back to top
View user's profile Send private message
adekoba
Tux's lil' helper
Tux's lil' helper


Joined: 06 Oct 2006
Posts: 129

PostPosted: Sat Jan 27, 2007 3:22 pm    Post subject: Reply with quote

Ha1f wrote:
dark_speedo wrote:
does anybody know how to make an alias that cd's normally into the arguments given and then ls's that directory? thanks


alias cdls="cd $1 && ls"


i tried that but it only ls's that directory, it doesn't cd into it
_________________
website
Back to top
View user's profile Send private message
InfinityX
Guru
Guru


Joined: 31 Jan 2004
Posts: 385

PostPosted: Sat Jan 27, 2007 5:46 pm    Post subject: Reply with quote

dark_speedo wrote:
does anybody know how to make an alias that cd's normally into the arguments given and then ls's that directory? thanks

I don't think you can make aliases that use arguments unless you're using csh, you're only option is to write a function:
Code:
cdls () { cd $* && ls --color=auto }

This works in zsh and it should work in bash too.
Back to top
View user's profile Send private message
dforsyth
n00b
n00b


Joined: 29 Jan 2005
Posts: 26
Location: College Park, Murdaland

PostPosted: Sat Jan 27, 2007 11:38 pm    Post subject: Reply with quote

worked for me in bash :?
_________________
O
4~ <-- me, fapping to Palin.
/\ `_
Back to top
View user's profile Send private message
RobertDavid
Apprentice
Apprentice


Joined: 08 Aug 2005
Posts: 271
Location: Czech Republic

PostPosted: Sat Feb 10, 2007 9:46 am    Post subject: Bash shortcuts CENTRAL:) Reply with quote

Hi everyone,
recently I find out the strenghts of command line and begun making a shortcuts and I wanted to make a thread to share our shortcuts, aliases, functions etc. :)

Feel free to post yours.

Code:

robert@robert-pokoj ~ $ shortcat
alias emerge='emerge_with_indexing_for_cfg-update'
alias set-clock="ntpclockset 81.0.235.220"
alias bashrc="source ~/.bashrc"
alias saverup="xautolock -enable"
alias saverdown="xatolock -disable"

fontref () { mkfontscale && mkfontdir && xset fp rehash; }
ref () { env-update && source /etc/profile; }
conkyref () { killall conky
      conky -d; }

alias mc="mc -b"
alias sumc="sudo mc -b"
alias edit="mc -b -e"
alias suedit="sudo mc -b -e"
alias editfvwm="mc -b ~/.fvwm"
alias shortcuts="mc -b -e /home/robert/.shortcuts"
alias shortcat="cat /home/robert/.shortcuts"
alias edit-keywords="mc -b -e /etc/portage/package.keywords"
alias edit-make="mc -b -e /etc/make.conf"
alias edit-mask="mc -b -e /etc/portage/package.mask"
alias edit-unmask="mc -b -e /etc/portage/package.unmask"
alias edit-use="mc -b -e /etc/portage/package.use"
alias edit-cflags="sudo mc -b /etc/portage/env /etc/portage/env"
alias updatepv="emerge -pvuND world"
update () { emerge -uDN world
    cfg-update -u
    localepurge; }
kernelmake () { make bzImage
make modules
make modules_install; }

alias pocasi="weather.py LKPR"

alias my-mplayer='mplayer -font "/usr/share/fonts/corefonts/arial.ttf" -subcp cp1250 -subfont-text-scale 4 -vf spp "6" -af volnorm "1:0.7" -ac mad -dr'
alias rip2ogg="rip -S -O -q 5"
alias webupdate="rsync -r --delete /home/robert/web/ /var/www/localhost/htdocs"
alias profili="wine /home/robert/Progs/profili/PROFILI.EXE"
alias print-file="lpr -o media=A4 -o lpi=7 -o cpi=14 -o page-left=15 -o page-top=30 -o page-right=15"
alias print-admin="elinks -no-connect http://localhost:631/admin"
alias iso2cd="cdrecord dev=/dev/hda -dao -eject -force"
alias dvd="mplayer -slang cs dvd://"
alias compufoil="wine /home/robert/Progs/compufoil/Cfwin.exe"
alias cdcopy="cdrdao copy --device /dev/cdrw --source-device /dev/dvd --on-the-fly --speed"
alias cdblankall="cdrecord -force dev=/dev/hda blank=all"
alias cdblank="cdrecord -force dev=/dev/hda blank=fast"
hpup () { amixer -q sset "External Amplifier" unmute && amixer -q sset Side unmute; }
hpdown () { amixer -q sset "External Amplifier" mute && amixer -q sset Side mute; }
alias mpdupdate="sudo /usr/local/bin/mpdupdatedb"
webstatupdate  () { sudo awstats_updateall.pl now
    sudo awstats_buildstaticpages.pl -config=localhost -dir=/var/www/localhost/awstats; }
alias webstats="elinks --no-connect /var/www/localhost/awstats/awstats.localhost.html"

alias sokoban="/usr/local/games/csokoban"
alias mines="/usr/local/games/cmines"

_________________
Arch & Fluxbox & 2.6.24-rc-zen!!!!
robertek.brevnov.net
Back to top
View user's profile Send private message
Maedhros
Bodhisattva
Bodhisattva


Joined: 14 Apr 2004
Posts: 5511
Location: Durham, UK

PostPosted: Sat Feb 10, 2007 10:47 am    Post subject: Reply with quote

Moved from Gentoo Chat to Documentation, Tips & Tricks.
_________________
No-one's more important than the earthworm.
Back to top
View user's profile Send private message
xentric
Guru
Guru


Joined: 16 Mar 2003
Posts: 410
Location: Netherlands

PostPosted: Sat Feb 10, 2007 10:52 am    Post subject: Reply with quote

alias c='clear'
alias confcat='sed -e '\''s/#.*//;/^\s*$/d'\'' '
alias d='ls -al'
alias envg='env|grep'
alias exe='chmod 755'
alias emerge='emerge_with_indexing_for_cfg-update'
alias h='history'
alias hg='history | grep'
alias kernel='cat /proc/sys/kernel/ostype;cat /proc/sys/kernel/osrelease'
alias mem='watch -n1 free'
alias n='nano -w'
alias nano='nano -w'
alias p='cd $OLDPWD'
alias psg='ps aux|grep'
alias unmerge='emerge -C'
alias x='exit'
alias xen='chown -R xentric:users'
_________________
When all else fails, read the manual...
Registered Linux User #340626
Back to top
View user's profile Send private message
RobertDavid
Apprentice
Apprentice


Joined: 08 Aug 2005
Posts: 271
Location: Czech Republic

PostPosted: Sat Feb 10, 2007 11:27 am    Post subject: Reply with quote

Maedhros wrote:
Moved from Gentoo Chat to Documentation, Tips & Tricks.


Thanks that you moved this thread to its apropriate place (I just didnot know where to place it best)

To XENTRIC:
Nice I have adopted your clear, exit, chmod and chown aliases:)
_________________
Arch & Fluxbox & 2.6.24-rc-zen!!!!
robertek.brevnov.net
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Germany

PostPosted: Sat Feb 10, 2007 3:03 pm    Post subject: Reply with quote

Moved from Off the Wall to Documentation, Tips & Tricks and merged with a thread there.
_________________
KDE
Back to top
View user's profile Send private message
booldog
n00b
n00b


Joined: 26 Aug 2005
Posts: 25
Location: Ohio, USA

PostPosted: Fri Feb 16, 2007 2:41 pm    Post subject: Reply with quote

cd fun
====

With all the 'cd' related aliases, I don't recall seeing:

# processes symbolic links first AND (best of all) tells you where you are physically, instead of logically
alias cd='cd -P'

Also, to go back to the prior folder, no mention of:

cd -

oracle fun
======
- entering sql to take user to same folder every time, great for accessing favorite sql scripts and using the same user-defined configuration every time.
- requirements:
folder in home directory called sql+
file called login.sql in sql+ directory
must have ex (vi)
following 2 aliases defined:
Code:
alias zz='echo "%s/\(set sqlprompt\).*/\1 \"SQL [${ORACLE_SID}]> \"/
%s/\(set linesize\).*/\1 `tput cols`/
wq" | ex -s ${HOME}/sql+/login.sql'
alias sql='(zz; cd ~/sql+; sqlplus /; cd -'

- login.sql must contain
Code:
set sqlprompt "SQL [any SID since this is updated by zz]> "
set linesize 135

Both these lines are updated by zz
Put in any other favorites, such as (sample):
Code:
prompt login.sql loaded
!( echo "currently in \c"; pwd)
prompt
set sqlprompt "SQL [any SID since this is updated by zz]> "
set linesize 135
set pagesize 40000
set trimspool on
set timing on
column question_name heading "Question|Name" format a8
set echo on

- notes
I use with ops$ account for instant access based on *nix login, not tested with login/password entry
- helpful shell script to save afiedt.buf in a numbered fashion, cool since you're always in the same working folder and probably want to keep those hot scripts trapped in the buffer
Code:
#! /bin/sh
# run [b]kb[/b] from command line or from sqlplus as [b]!kb[/b]

[ -f "afiedt.buf" ] || exit 1

NUM=$(ls afiedt.[0-9]* 2> /dev/null | cut -d "." -f2 | sort -rn | line)
[ -z "${NUM}" ] && NUM="0"
NUM=$(printf %03d $(expr ${NUM} + 1)
mv afiedt.buf afiedt.${NUM}

_________________
Cheers,
ND
Back to top
View user's profile Send private message
grooveharder
n00b
n00b


Joined: 18 Feb 2007
Posts: 44

PostPosted: Sun Feb 18, 2007 5:40 pm    Post subject: Reply with quote

i wanted to find a way of estimating how far a certain emerge was in compiling, so i created this - any suggestions/improvements?
/usr/bin/count:
Code:
#!/bin/sh

O=`find $1 -name *.o | wc -l`
CCOUNT=`find $1 \( -name "*.c" -o -name "*.cc" -o -name "*.cpp" -o -name "*.cxx" \) -print | wc -l`


echo $O / $CCOUNT


eg count /var/tmp/portage/foo-2.4.1
Back to top
View user's profile Send private message
Dralnu
Veteran
Veteran


Joined: 24 May 2006
Posts: 1919

PostPosted: Sat Apr 28, 2007 7:24 pm    Post subject: Reply with quote

Sometimes a thread deserves to be resurected.
_________________
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
Back to top
View user's profile Send private message
Dralnu
Veteran
Veteran


Joined: 24 May 2006
Posts: 1919

PostPosted: Sun May 27, 2007 2:21 am    Post subject: Reply with quote

Something I made up:

First part here I got in this thread I think:
Code:
i18n_purge() {
pushd . >/dev/null 2>&1

cd /usr/share/locale

for dir in `\ls --ignore=bg* --ignore=ja* --ignore=en* --ignore=ru* --ignore=de* --ignore=locale.alias --ignore=C --ignore=POSIX`
do rm -rf $dir
done

cd /usr/share/man

for dir in `\ls --ignore=bg* --ignore=ja* --ignore=en* --ignore=ru* --ignore=man*`
do rm -r $dir
done

popd >/dev/null 2>&1; echo "Done."
}


I'd like to strip out a bit more, but I don't know what I can remove and what not...

Now for the big one:

Code:
sysclean() {
echo -n "Running sysclean. First step: emerge --depclean\n\n\n"
sleep 5
echo -n "Running emerge --depclean...\n\n\n"
emerge --depclean -v

echo -n "\n\n\nSecond Step: revdep-rebuild\n\n\n"
sleep 5
echo -n "Running revdep-rebuild...\n\n\n"
revdep-rebuild

echo -n "\n\n\nThird Step: i18n_purge\n\n\n"
sleep 5
echo -n "Running i18n_purge...\n\n\n"
yes | i18n_purge

echo -n "\n\n\nFinal Step: eclean-dist -d\n\n\n"
sleep 5
echo -n "Running eclean-dist -d...\n\n\n"
eclean-dist -d

echo "\n\n\nDone. System has been cleaned.\n\n\n"
}


Bet you can't guess what that does!

The logic in the order:

Once you've run --depclean, running revdep-rebuild will (hopefully) resolve any issues before going through (and thus hopefully avoiding the hassle of a recompile) with removing locales, and the distfiles. I use i18n_purge instead of localepurge because well, it does the same thing, and does it just as well, without requiring one to run perl..

Edit: Added some additional info
_________________
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
Back to top
View user's profile Send private message
Dralnu
Veteran
Veteran


Joined: 24 May 2006
Posts: 1919

PostPosted: Thu May 31, 2007 4:58 am    Post subject: Reply with quote

for those who use screen with rtorrent:

run rtorrent as:

nice --adjustment=15 rtorrent

to save yourself some headaches when checking a hash.
_________________
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
Back to top
View user's profile Send private message
melange
Tux's lil' helper
Tux's lil' helper


Joined: 16 Sep 2004
Posts: 110

PostPosted: Sun Dec 09, 2007 10:14 pm    Post subject: Share you totally awesome shell tips Reply with quote

Do as the topic says, share your tips and great ideas :)

It could be anything from an awesome script like unfoo, to something really useful shell utils like CTRL+C, bg, fg and jobs, or absolutely useless like "/usr/bin/yes" or "/usr/games/banner"
Back to top
View user's profile Send private message
mdeininger
Veteran
Veteran


Joined: 15 Jun 2005
Posts: 1740
Location: Emerald Isles, observing Dublin's docklands

PostPosted: Sun Dec 09, 2007 10:17 pm    Post subject: Reply with quote

ctrl+s & ctrl+q

ctrl+s will freeze the console,
ctrl+q will thaw it back up.

pretty useful if you have a lot of output scroll by really fast and you need to examine something in the middle that's getting pushed outta that annoyingly small scrollback buffer too fast.
_________________
"Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland

( Twitter | Blog | GitHub )
Back to top
View user's profile Send private message
bunder
Bodhisattva
Bodhisattva


Joined: 10 Apr 2004
Posts: 5933

PostPosted: Sun Dec 09, 2007 10:21 pm    Post subject: Reply with quote

alias stuff.

Quote:
alias duh='du -h --max-depth=1'
alias grep='grep --colour=auto'
alias h='history | tail -n 50'
alias ls='ls --color=auto'
alias nano='nano -w'
alias netstat='netstat --inet'
alias pico='pico -w'
alias quota='quota -s'
alias screen='screen -U'

_________________
Neddyseagoon wrote:
The problem with leaving is that you can only do it once and it reduces your influence.

banned from #gentoo since sept 2017
Back to top
View user's profile Send private message
melange
Tux's lil' helper
Tux's lil' helper


Joined: 16 Sep 2004
Posts: 110

PostPosted: Sun Dec 09, 2007 10:27 pm    Post subject: Reply with quote

mdeininger wrote:
ctrl+s & ctrl+q

ctrl+s will freeze the console,
ctrl+q will thaw it back up.

pretty useful if you have a lot of output scroll by really fast and you need to examine something in the middle that's getting pushed outta that annoyingly small scrollback buffer too fast.


hmm. I can't get that working. Which shell are you using? (I tried with bash and zsh)
Back to top
View user's profile Send private message
petrjanda
Veteran
Veteran


Joined: 05 Sep 2003
Posts: 1557
Location: Brno, Czech Republic

PostPosted: Sun Dec 09, 2007 10:31 pm    Post subject: Reply with quote

rm -rf / will make your penis grow bigger and your woman will not want another man in bed.
_________________
There is, a not-born, a not-become, a not-made, a not-compounded. If that unborn, not-become, not-made, not-compounded were not, there would be no escape from this here that is born, become, made and compounded. - Gautama Siddharta
Back to top
View user's profile Send private message
mdeininger
Veteran
Veteran


Joined: 15 Jun 2005
Posts: 1740
Location: Emerald Isles, observing Dublin's docklands

PostPosted: Sun Dec 09, 2007 10:38 pm    Post subject: Reply with quote

melange wrote:
mdeininger wrote:
ctrl+s & ctrl+q

ctrl+s will freeze the console,
ctrl+q will thaw it back up.

pretty useful if you have a lot of output scroll by really fast and you need to examine something in the middle that's getting pushed outta that annoyingly small scrollback buffer too fast.


hmm. I can't get that working. Which shell are you using? (I tried with bash and zsh)
it's a terminal function... works on "real" virtual terminals on tty1 and the like, and on virtual terminals like xterm... at least those're the only ones i tried it on.

EDIT: try with a script like this one:
Code:
while sleep 1; do echo .; done

_________________
"Confident, lazy, cocky, dead." -- Felix Jongleur, Otherland

( Twitter | Blog | GitHub )
Back to top
View user's profile Send private message
PraetorZero
Apprentice
Apprentice


Joined: 11 Dec 2004
Posts: 239
Location: /home

PostPosted: Sun Dec 09, 2007 10:45 pm    Post subject: Re: Share you totally awesome shell tips Reply with quote

melange wrote:
Do as the topic says, share your tips and great ideas :)

It could be anything from an awesome script like unfoo, to something really useful shell utils like CTRL+C, bg, fg and jobs, or absolutely useless like "/usr/bin/yes" or "/usr/games/banner"


What does yes do? Just do a Y and carriage return?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3 ... 11, 12, 13, 14, 15, 16  Next
Page 12 of 16

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum