You searched for articles tagged with Shell.

[ #181 ] Learning zsh Permalink

zsh, Shell Added less than a year ago

My initial keybindings:

zsh $ bindkey -v # sets vi mode
zsh $ bindkey '^R' history-incremental-search-backward # like ctrl-R in bash

... and how cool is r?

zsh $ echo "hey dude"
hey dude
zsh $ r dude=guy
echo "hey guy"
hey guy

A sweet cheat-sheet is here.




[ #172 ] Splitting Screen in Half Permalink

Shell Added less than a year ago and last edited less than a year ago

(We're talking about GNU Screen here.)

From this tutorial:

Splitting the screen in half horizontally

To split the screen in two, first create two screen sessions. Then press Ctrl+a S which will split the screen in half, giving you a session on the top that you're already using and a blank session at the bottom.

To move to the bottom half, press Ctrl+a, then the TAB key. This key combination will move the console cursor to the lower half. Once in the blank half, you have to set this bottom half of the screen to use one of the two earlier created sessions. To do this, press Ctrl+a, then " (shift+'). You will be presented with a list of available screen sessions, pick one using the arrow keys (be careful not to pick the one already at the top or you'll have a mirror console), and activate it by pressing Enter. Now type top and switch to the upper half by pressing again Ctrl+a TAB. You should now have a bash prompt waiting for commands in the upper half and system resources monitoring in the bottom half.

What a pain! Luckily I don't find myself needing to do this ;\




[ #169 ] Screen Commands Permalink

Shell Added less than a year ago

Within a screen session you can issue any available command by pressing Ctrl-a, then typing :commandhere

For example, to change the current screen session name:

Ctrl-a
:sessionname project



[ #149 ] Yesterday's Date Permalink

Shell, Linux Added less than a year ago

Using date you can do some nifty things with human-readable dates:

$ date +%Y%m%d
20090915
$ date -d '1 day ago' +%Y%m%d
20090914

This works with the date that comes with my Slackware distribution (and probably most/all Linux distributions) but not with my Mac OS X date.




[ #148 ] Downloading mp3s with wget Permalink

Shell Added less than a year ago

Perhaps you read some blogs that link to mp3s and you'd like to grab all these files in one go. Firstly, populate a file called mp3.txt with a list of the blog URLs you have, separated by new lines. Then run wget like so:

$ wget -r -l1 -H -t1 -nd -N -np -A.mp3 -i mp3.txt

... and wait a while. I just downloaded about 50 mp3s from four different starting sites.




[ #143 ] Examine Source of any Perl Module in your Path Permalink

Perl, Shell Added less than a year ago

Perldoc helps out:

$ less `perldoc -l strict`

... gives us a look at strict.pm.




[ #138 ] Please use /usr/bin/env Permalink

Shell Added less than a year ago

For your scripts/programs, instead of:

#!/usr/bin/python
#!/usr/bin/perl
#!/usr/bin/ruby
#!/bin/bash

use env instead. How?

#!/usr/bin/env perl
#!/usr/bin/env python
#!/usr/bin/env ruby
#!/usr/bin/env bash

What does env do?

It finds the executable for you, in your path.

Why should you?

Because almost every system (except apparently certain versions of Unicos and Openserver) has the env program in /usr/bin/, but the perl or python or ruby or bash executable is more often found in a different directory than /usr/bin/.

Really? Where else could they be?

I've seen them in:

/usr/local/bin
/opt/local/bin
/usr/pkg/bin

...etc. They could be installed anywhere actually. Perhaps even your home directory. /usr/bin/env solves this portability problem when you try to run a script on a machine with different location for perl/python/ruby/bash etc.

But on my system, env is in /bin/ not /usr/bin

No it isn't. Look in /usr/bin/ too - I'll bet you find it. If you really don't, then you are using a pretty strange system (perhaps Unicos or something) - in which you might have many greater portability problems than this.

Is there any sitution where I should NOT use /usr/bin/env?

Yeah there could be. Let's say you have multiple versions of perl installed on your system - 5.8 and 5.6, where the main perl in your path points to 5.8. You could have a script that purposely needs to use 5.6 instead of 5.8 because of certain compatibility problems. In this case you might want to use #!/full/path/to/perl5.6 not #!/usr/bin/env.




[ #125 ] Exim Tidbits Permalink

Exim, Shell Added less than a year ago and last edited less than a year ago

Test whether exim will accept delivery for an address:

# exim -bt you@yourserver.tld

Send an email from the console:

# exim -v -odf someone@elsewhere.tld

Show the queue:

# mailq

Manually run through the queue:

# exim -v -q



[ #115 ] iconv Unicode Converter Permalink

Shell Added a year and a bit ago

I always forget what iconv is called, so this entry is just a memory assistant:

$ iconv -f ISO-8859-1 -t UTF-8 filename.txt



[ #114 ] Using Git for Server Configs Permalink

Git, Shell, Apache Added a year and a bit ago and last edited a year and a bit ago

I dev on a VM that has at least two projects running with incompatible apache httpd.conf files. The differences include User/Group, Location etc, so I switch between the configs and then restart apache httpd when I want to work on a particular project.

Firstly, I understand that some or all of my different settings could be merged into one conf file and made to work on different virtual hosts etc, but in some situations you can't do this because: you only want one project running off your dev server at a time due to performance/load issues; or you have a specific file you need to use as a httpd conf file from your codebase etc.

So - I used git to help me switch between configs.

# cd /etc/apache2
# git add apache2.conf
# git commit
# git tag projA
# vim apache2.conf # or cp your apache2.conf for projB into place
# git add apache2.conf
# git commit
# git tag projB
# echo "/etc/init.d/apache2 restart" > .git/hooks/post-checkout
# chmod a+x .git/hooks/post-checkout

... now you are setup! So when you want to switch to projA you do this:

# cd /etc/apache2 && git checkout projA

... and to switch back to projB use:

# cd /etc/apache2 && git checkout projB

... and your apache will automatically restart after each checkout.

Yes you could do this just by copying your files into place but I think this is a neat use of git and one that will scale over many projects and many revisions of the conf files.

UPDATE

Instead of using tags, use branches! That way you can update the conf files, commit, and then continue using the projA and projB identifiers.




Older Posts ... Newer Posts

Colophon

Django Python 960.gs Git Vim NetBSD Nginx

The Author

This is the blog of Brad Willis, a software engineer living in Brisbane.

Meta

Help
Latest entries

*BSD Agile Apache Apple apt Athletics Best-Practice Censorship Comedy Cool Crosswords Deployment Django English Exim Firefox Git Hardcore Health irssi Javascript Jira Languages Linux Makefile Mathematics Mobile Broadband Mutt MySQL NetBSD nginx Nokia OpenVZ OSX Perl Privacy Python Rant Requirements rsync Ruby Shell Slackware SQL SQLite SSH Standards Subversion Television Testing ThisBlog Vim VMWare (Fusion) VPN X zsh

Recent Entries

Checking for exceptions in doctests
Homer's Curling Speech
retry in Python
Vim Makefile tabs
Centos (or RH) IPTables
Converting ssh2 public keys to openssh
Vim comment hints
Context managers in Perl
Dish rotation
Git - fixing commit user
apt stuff
Using shell variables in AWK
Linux - Too many open files
Tell gvim to save and quit... remotely
Vim - automatically remove whitespace at EOL
Python - relative paths from within modules
TV Aspect Ratios
Git - Which commits are in your branch only?
Subversion setup cheat sheet
Force detach a screen session
Modify sudo's use of environment variables
Install all Perl modules
Mutt - delete old messages
OpenVZ VPS and swap space
fail2ban on NetBSD for ssh
NetBSD - Using sup
Python - testing for a sys.exit
Python Best Practice Link Dump
Python script names
Perl - Using an expensive module
Speed of git clone
Perl Modules with Custom Prefix
Perl: tr vs. s
Brilliant sysadmin Reference
Why is GRUB better than LILO?
Why is swap space important?
Perldoc Output
Git's Index
Jira Project Keys
Git GUI

Links

ChoppingBoard, DaveMisc, Project365, RageQuit