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

Goto page 1, 2, 3 ... 13, 14, 15  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214
Location: Madtown, WI

PostPosted: Tue Sep 17, 2002 11:36 pm    Post subject: Console / shell tips & tricks Reply with quote

Yes, we all know how to alias stuff in /etc/profile or ~/.bashrc or whatever. Some favorites of (seemingly) everyone are:
Code:
alias ls='ls --color'
alias sl='ls --color'
The list is brief, but that's where the rest of this thread comes into play: What are some quick little console (if you want X-tricks, start another thread, please!) tricks that you employ?

Here are some of mine:
script called "remote" that can optionally take in an argument. If there is an argument, it's a nickname for an ssh server. If there is no argument, list the predefined ssh servers and pick from the menu. This is useful if you like to forward ports often.
alias rm='rm -f' I'm feeling lucky :D


EDIT: Title was "quick console tricks" --pjp
_________________
Get Firefox!

Proper Web Development

I'm done at 999.
Back to top
View user's profile Send private message
nitro322
Guru
Guru


Joined: 24 Jul 2002
Posts: 551
Location: USA

PostPosted: Wed Sep 18, 2002 5:14 am    Post subject: Reply with quote

Code:
alias 2000='su -c "lilo -R 2000" && reboot'

reboot to Windows 2000 without the LILO prompt
2000 = the lilo name for my Windows 2000 entry
Code:
alias c='clear'
alias md='mkdir'
alias rd='rmdir'
alias dir='ls -Alh --color | more'

I'm lazy :-)
Code:
alias gpm='sudo /etc/init.d/gpm start'
alias halt='sudo /sbin/halt'
alias reboot='sudo /sbin/reboot'
alias renet='sudo /etc/init.d/net.eth0 restart'

more various shortcuts to save me time
Code:
alias kernel_comp='cd /usr/src/linux/ && cp .config .. && make clean && make mrproper && cp ../.config . && make menuconfig && make dep && make bzImage modules modules_install && cp System.map /boot/System.map-020916 && cp arch/i386/boot/bzImage /boot/bzImage-020916 && lilo && echo "finished"'

who's your daddy? :wink:

I guess that's just about it. I also run my console at 1024x768 resolution with 8-bit color, which gives me a LOT more room to work, in addition to being purtier. If you haven't noticed, the left and right windows keys on your keyboard will change you to the virtual terminal to the left and right of your current one. Nice.
Back to top
View user's profile Send private message
dioxmat
Bodhisattva
Bodhisattva


Joined: 04 May 2002
Posts: 709
Location: /home/mat

PostPosted: Wed Sep 18, 2002 8:18 am    Post subject: Reply with quote

nitro322 wrote:

Code:
alias kernel_comp='cd /usr/src/linux/ && cp .config .. && make clean && make mrproper && cp ../.config . && make menuconfig && make dep && make bzImage modules modules_install && cp System.map /boot/System.map-020916 && cp arch/i386/boot/bzImage /boot/bzImage-020916 && lilo && echo "finished"'

who's your daddy? :wink:



nah, you forgot to evaluate the time it took :)
Back to top
View user's profile Send private message
fmalabre
Guru
Guru


Joined: 19 Jun 2002
Posts: 376
Location: Chicago

PostPosted: Wed Sep 18, 2002 3:57 pm    Post subject: Reply with quote

nitro322 wrote:
reboot to Windows 2000 without the LILO prompt

Can we do the same thing with Grub?
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 16103
Location: Colorado

PostPosted: Wed Sep 18, 2002 6:56 pm    Post subject: Reply with quote

I could've sworn I'd seen it done somewhere, but I'm not finding it.
_________________
lolgov. 'cause where we're going, you don't have civil liberties.

In Loving Memory
1787 - 2008
Back to top
View user's profile Send private message
rojaro
l33t
l33t


Joined: 06 May 2002
Posts: 732

PostPosted: Wed Sep 18, 2002 8:24 pm    Post subject: Reply with quote

there is no such function in grub and there are just two "halfway methods" which work ... well just half the way ...

1. is to use multiple menu.lst files and a shellscript which exchanges the config files (which is pretty easy to implement)

2. use a shellscript which changes the "default"-parameter in the menu.lst file using sed (imho the nicer way). this shellscript should reset the menu.lst to the real default when called without parameters and you could add it to /etc/conf.d/localstart to change the parameter back to default automatically on next linuxboot ...

sure you'll see why this is only a halfway solution ...

[edit: ... just filed a feature request at their bugzilla]
_________________
A mathematician is a machine for turning coffee into theorems. ~ Alfred Renyi (*1921 - †1970)


Last edited by rojaro on Wed Sep 18, 2002 8:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
NickDaFish
Tux's lil' helper
Tux's lil' helper


Joined: 12 Sep 2002
Posts: 112
Location: Boston, USA

PostPosted: Wed Sep 18, 2002 8:26 pm    Post subject: Reply with quote

Quote:
alias ls='ls --color'

:D YES! Many thanks! I've been trying to work out how to make bash do that for AGES! It's default in RedHat and I've been missing it ever since I went over to Gentoo... Too many other things to figure out first :wink: so I never go to it.

BTW Does anyone know how to get my Home key to work with in a PuTTY SSH session? I think it's something to do with inputrc..... I have Ctrl-a to get me by for now but I'd it would be nice to get my keyboard to work as advertised :?
Back to top
View user's profile Send private message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214
Location: Madtown, WI

PostPosted: Fri Sep 20, 2002 5:28 am    Post subject: forgot one Reply with quote

(Using lynx while bootstrapping, so I don't know how this'll turn out.)

I forgot one very key alias in my first post:
Code:
alias pico='nano -w'
And life just became much easier. : )
_________________
Get Firefox!

Proper Web Development

I'm done at 999.
Back to top
View user's profile Send private message
phong
Bodhisattva
Bodhisattva


Joined: 16 Jul 2002
Posts: 778
Location: Michigan - 15 & Ryan

PostPosted: Fri Sep 20, 2002 2:41 pm    Post subject: Reply with quote

I have lots of aliases to save myself some typing, many are either from DOS or even from .bat files I made in the DOS days for the same purpose:
Code:
alias vi='vim -o -X'
alias vim='vim -o -X'
alias vimdiff='vimdiff -X'
alias dir='ls --color -Flh'
alias dirh='ls --color -Flah'
alias di='dir' # my most common command line typo is hitting enter before 'r' in dir
alias r=''
alias cls='clear' # actually, I usually just hit ctrl-l
alias x='exit'
alias rd='rmdir'
alias md='mkdir'
alias h='history'
alias mo='more'
alias le='less'
alias ks='kfmclient exec' # like the windows "start" command
alias nc='mc'

alias cd/='cd /'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

_________________
"An empty head is not really empty; it is stuffed with rubbish. Hence the difficulty of forcing anything into an empty head."
-- Eric Hoffer
Back to top
View user's profile Send private message
tactless
l33t
l33t


Joined: 14 Jul 2002
Posts: 642
Location: Mitzpe Adi, Israel

PostPosted: Mon Sep 23, 2002 6:25 am    Post subject: Reply with quote

Not really a "trick", but here's something I put in my bashrc:
Code:
fortune


Great way to start the day :)[/code]
_________________
Tactless

"If it wasn't for fog, the world would run at a really crappy framerate."

Jabber: tactless@amessage.info
Back to top
View user's profile Send private message
wbsoft
n00b
n00b


Joined: 26 Aug 2002
Posts: 73
Location: the Netherlands

PostPosted: Mon Sep 23, 2002 8:03 am    Post subject: Reply with quote

Code:

nd() { test -d "$1" || mkdir "$1" && cd "$1" ; }
alias o="less -iMS"
nX()
{
  for i in `seq 0 9`
  do
    if [ ! -e "/tmp/.X${i}-lock" ] ; then
      XFree86 ":$i" -query localhost &
      break
    fi
  done
}

the last one, nX, starts a new X login on a new display. (You should add localhost to /etc/X11/xdm/Xaccess)
Back to top
View user's profile Send private message
squanto
Guru
Guru


Joined: 20 Apr 2002
Posts: 524
Location: Rochester, NY, USA

PostPosted: Fri Sep 27, 2002 4:47 am    Post subject: Reply with quote

I read somewhere how to customize bash, with like the full current directory path, the time, and a whole bunch of other things. Any one want to give me a quick heads up to an article on how to do this?
I think it fits in with neat things to do with customizing your shell.

thanks!
Back to top
View user's profile Send private message
carlivar
Tux's lil' helper
Tux's lil' helper


Joined: 22 Jul 2002
Posts: 92
Location: Burbank, California

PostPosted: Fri Sep 27, 2002 7:34 am    Post subject: Reply with quote

squanto wrote:
I read somewhere how to customize bash, with like the full current directory path, the time, and a whole bunch of other things. Any one want to give me a quick heads up to an article on how to do this?


Go here for a very nice thread with many bash prompt examples.

Carl
_________________
"It is difficult to make our material condition better by the best law, but it is easy enough to ruin it by bad laws." - Theodore Roosevelt
Back to top
View user's profile Send private message
squanto
Guru
Guru


Joined: 20 Apr 2002
Posts: 524
Location: Rochester, NY, USA

PostPosted: Mon Sep 30, 2002 1:13 am    Post subject: Reply with quote

carlivar wrote:
squanto wrote:
I read somewhere how to customize bash, with like the full current directory path, the time, and a whole bunch of other things. Any one want to give me a quick heads up to an article on how to do this?


Go here for a very nice thread with many bash prompt examples.

Carl

Hey, thanks!
I read an article about customizing bash in CPU mag, but misplaced the article.
I don't like how gnome's term doesn't list anything.
as for my aliases: alias sshserver="ssh my.server.name.edu"
so I can ssh into my game server ;) (modified obviously)

Andrew
Back to top
View user's profile Send private message
NiklasH
Apprentice
Apprentice


Joined: 30 Aug 2002
Posts: 211
Location: On top of something

PostPosted: Wed Oct 02, 2002 9:48 am    Post subject: Reply with quote

wbsoft wrote:
Code:

nd() { test -d "$1" || mkdir "$1" && cd "$1" ; }
alias o="less -iMS"
nX()
{
  for i in `seq 0 9`
  do
    if [ ! -e "/tmp/.X${i}-lock" ] ; then
      XFree86 ":$i" -query localhost &
      break
    fi
  done
}

the last one, nX, starts a new X login on a new display. (You should add localhost to /etc/X11/xdm/Xaccess)


I can't get this to work...
The nX function starts a new X window, but I get no login prompt (gdm, in my case).
Am I doing something wrong? I tried to add just 'localhost' in Xaccess. Should I add something more? I also tried to add CHOOSER localhost, but that didn't work either.
Maybe I'm just stupid... :? But I would really like this to work, so any help is very appreciated!
Back to top
View user's profile Send private message
klieber
Administrator
Administrator


Joined: 17 Apr 2002
Posts: 3657
Location: San Francisco, CA

PostPosted: Wed Oct 02, 2002 5:32 pm    Post subject: Reply with quote

I find it remarkable how many people don't use the history command. That, combined with the '!n' to re-issue a frequently-used command saves me tons and tons of time.

man history if you have no idea what I'm talking about.

--kurt
_________________
The problem with political jokes is that they get elected
Back to top
View user's profile Send private message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214
Location: Madtown, WI

PostPosted: Wed Oct 23, 2002 6:14 am    Post subject: Reply with quote

I definitely do not claim to be a proficient bash programmer. But hey, it works. I call it 'remote':
Code:
#!/bin/bash
SERVERS="CAE CS Quit"
ENGR="cae.my_u.edu"
COMPSCI="cs.my_u.edu"
if [ -z "$1" ]; then
   select serv in $SERVERS; do
      if [ "$serv" = "CAE" ]; then
         ssh $ENGR
         exit
      elif [ "$serv" = "CS" ]; then
         ssh $COMPSCI
         exit
      elif [ "$serv" = "Quit" ]; then
         exit
      else
         echo bad option
         echo
      fi
   done
else
   if [ "$1" = "cae" ]; then
      ssh $ENGR
   elif [ "$1" = "cs" ]; then
      ssh $COMPSCI
   else
      echo Bad argument.  Servers are cs or cae
      echo eg:  remote cae
   fi
fi

_________________
Get Firefox!

Proper Web Development

I'm done at 999.
Back to top
View user's profile Send private message
carambola5
Apprentice
Apprentice


Joined: 10 Jul 2002
Posts: 214
Location: Madtown, WI

PostPosted: Tue Jan 14, 2003 9:52 pm    Post subject: Reply with quote

screenie:
Code:

#!/bin/bash
PICPATH=$HOME/pictures/screenshots
INDEX=`cat $PICPATH/index.dat`
import -window root $PICPATH/ss$INDEX.png
echo $(($INDEX + 1)) > $PICPATH/index.dat


I mapped this to my printscreen key through .fluxbox/keys
_________________
Get Firefox!

Proper Web Development

I'm done at 999.
Back to top
View user's profile Send private message
H-Pi
Apprentice
Apprentice


Joined: 26 Jun 2002
Posts: 175
Location: Delft (NL)

PostPosted: Tue Jan 14, 2003 10:30 pm    Post subject: Reply with quote

nice thread!

Code:
alias es='emerge -s'
alias ep='emerge -p'
alias ue='ACCEPT_KEYWORDS="~x86" emerge'


Ihated to type ACCEPT_KEYWORDS="~x86, and didn't want to put it in my make.conf so made an alias for it, and then thought: why not es and ep too?

Quote:

I find it remarkable how many people don't use the history command.


I just use the tab, page-up and page-down buttons, they take away the need of an 'history'


Last edited by H-Pi on Tue Jan 14, 2003 10:52 pm; edited 2 times in total
Back to top
View user's profile Send private message
red_over_blue
Guru
Guru


Joined: 16 Dec 2002
Posts: 310

PostPosted: Tue Jan 14, 2003 10:46 pm    Post subject: Reply with quote

Code:

alias recal='history | grep'


You can then just type

Code:

!955


Supposing 955 was the line you wanted to execute again. I also like using ctrl-l for clear (screen) and ctrl-d to log-out.
Back to top
View user's profile Send private message
sa
Guru
Guru


Joined: 10 Jun 2002
Posts: 450

PostPosted: Wed Jan 15, 2003 1:06 am    Post subject: Reply with quote

Code:

alias play-dvd='xine --auto-play -s dvd'
xnest='Xnest -auth .Xauthority_blah -full -sync -name "Xnest :1" -fp `xset -q | grep fonts` :1'


:-)
Back to top
View user's profile Send private message
frew
n00b
n00b


Joined: 12 Nov 2002
Posts: 29

PostPosted: Wed Jan 15, 2003 1:32 am    Post subject: Reply with quote

Wow, history really is useful...Can't beleive I've never seen it before.

I know this is useless but I like it: (btw, you have to emerge cowsay first)
Code:

date +%l:%M| cowsay


I can't think of anything else at the moment...

Oh yeah, and put that in the begginging of .bashrc
Back to top
View user's profile Send private message
zojas
Veteran
Veteran


Joined: 22 Apr 2002
Posts: 1138
Location: Phoenix, AZ

PostPosted: Wed Jan 15, 2003 7:32 am    Post subject: Reply with quote

I use history substitution a lot. not only '!!' to repeat the last command, !23 to repeat command number 23, and !c to repeat the last command which started with 'c', but you can also use '!$' to get the last word from the previous command. so say you wanted to check for a package in the mask file, then edit it:

Code:
grep kde /usr/portage/profiles/package.mask
vim +/kde !$


before I started using etc-update I used to do this a lot:

Code:

diff net.eth0 ._cfg000.net.eth0
mv !$ !^


(!^ means the first argument of the previous command)

also !* means all the arguments from the previous command (without the program name)

Code:
diff net.eth0 ._cfg000.net.eth0
vim -o !*


also I make an alias called 'h' for the word 'history'
Back to top
View user's profile Send private message
Empty_One
n00b
n00b


Joined: 18 Oct 2002
Posts: 32

PostPosted: Wed Jan 15, 2003 3:44 pm    Post subject: Reply with quote

dumb question, but how is the hisory better than just cycling through the list with the up arrow? Seems like you would have to read thru the list anyway
_________________
"Barney sucks! Best Buy sucks! Sony Sucks! Microsoft sucks, Bill Gates is the anti-Christ and John Ashcroft can kiss my ass!" Wil Wheaton
Back to top
View user's profile Send private message
zojas
Veteran
Veteran


Joined: 22 Apr 2002
Posts: 1138
Location: Phoenix, AZ

PostPosted: Wed Jan 15, 2003 4:03 pm    Post subject: Reply with quote

with history you see it all at once. the eye travels faster than the fingers! try it, once you do it a few times you'll see.
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 1, 2, 3 ... 13, 14, 15  Next
Page 1 of 15

 
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