11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appen<strong>di</strong>ce A. Script aggiuntivi<br />

Written by Phil Braham. Realtime Software Pty Ltd.<br />

Released under GNU license. Free to use. Please pass any mo<strong>di</strong>fications<br />

or comments to the author Phil Braham:<br />

realtime@mpx.com.au<br />

===============================================================================<br />

cdll is a replacement for cd and incorporates similar functionality to<br />

the bash pushd and popd commands but is independent of them.<br />

This version of cdll has been tested on Linux using <strong>Bash</strong>. It will work<br />

on most Linux versions but will probably not work on other shells without<br />

mo<strong>di</strong>fication.<br />

Introduction<br />

============<br />

cdll allows easy moving about between <strong>di</strong>rectories. When changing to a new<br />

<strong>di</strong>rectory the current one is automatically put onto a stack. By default<br />

50 entries are kept, but this is configurable. Special <strong>di</strong>rectories can be<br />

kept for easy access - by default up to 10, but this is configurable. The<br />

most recent stack entries and the special entries can be easily viewed.<br />

The <strong>di</strong>rectory stack and special entries can be saved to, and loaded from,<br />

a file. This allows them to be set up on login, saved before logging out<br />

or changed when moving project to project.<br />

In ad<strong>di</strong>tion, cdll provides a flexible command prompt facility that allows,<br />

for example, a <strong>di</strong>rectory name in colour that is truncated from the left<br />

if it gets too long.<br />

Setting up cdll<br />

===============<br />

Copy cdll to either your local home <strong>di</strong>rectory or a central <strong>di</strong>rectory<br />

such as /usr/bin (this will require root access).<br />

Copy the file cdfile to your home <strong>di</strong>rectory. It will require read and<br />

write access. This a default file that contains a <strong>di</strong>rectory stack and<br />

special entries.<br />

To replace the cd command you must add commands to your login script.<br />

The login script is one or more of:<br />

/etc/profile<br />

~/.bash_profile<br />

~/.bash_login<br />

~/.profile<br />

~/.bashrc<br />

/etc/bash.bashrc.local<br />

To setup your login, ~/.bashrc is recommended, for global (and root) setup<br />

756

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!