Setting up eggdrop

Eggdrop is an open source IRC bot. Since no ArchWiki article exists for eggdrop, here’s a quick getting started guide.

Download the aur eggdrop package:

$ yaourt -S eggdrop

Copy the configuration file to a local directory:

# mkdir ~/.eggdrop
# cp /etc/eggdrop.conf ~/.eggdrop

Modify ~/.eggdrop/eggdrop.conf using the eggdrop wiki as a guide:
http://eggwiki.org/Eggdrop.conf

Start eggdrop:

cd ~/.eggdrop
eggdrop eggdrop.conf

Message your bot from your IRC client to setup an admin password:

/msg YourBotsName hello

Control your bot by via DCC:

/ctcp YourBotsName chat
/dcc chat YourBotsName

To start eggdrop when you startx, add to ~/.xinitrc:

cd ~/.eggdrop && eggdrop eggdrop.conf &

Fixing Cousine from ttf-google-webfonts

This refers to the latest ttf-google-webfonts aur package (version: 2369-1, revision: f50f26f0c77c).

Problem #1: tilde character looks like a dash when font size is less than 10
Problem #2: semicolon glyph is missing

I’ve entered a bug report here

Fix:

  1. Download latest files from the source:
    https://googlefontdirectory.googlecode.com/hg/cousine/src/
  2. Install fontforge
    # pacman -S fontforge
  3. Open Cousine-Regular.ttf in fontforge
  4. Element -> Font Info -> PS Names
  5. Change font name to distinguish it from the ttf-google-webfonts package
    Fontname: CousineRegen
    Family Name: Cousine Regen
    Name of Humans: Cousine Regen
  6. OK -> Change
  7. File -> Generate Fonts -> Truetype -> untick Validate before saving -> Save
  8. Repeat 3-7 for the bold, italic and boldItalic ttf files
  9. Add CousineRegen*.ttf to a directory in your FontPath
  10. Refresh font cache
    # fc-cache -fv

tl;dr: Source ttf fonts provide missing glyph. Regenerating fonts in fontforge fixes tilde character at low fontsizes.

Before vs after:

Make IPython recognise virtualenv

IPython doesn’t currently recognise when you’re in a virtualenv. (See high priority issue).

There are currently 3 popular workarounds for those without root access.

Workaround #1. Add the following to ~/.bashrc or ~/.zshrc:

alias ipython="python /usr/bin/ipython"

Workaround #2. Install a local virtualenv copy of ipython:

$ pip install ipython

Workaround #3. Create ~/.config/ipython/profile_default/ipython_virtualenv.py with the following (for Python3):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Modified for Python 3 (https://gist.github.com/1759781)
from os import environ
from os.path import join, sep
 
if 'VIRTUAL_ENV' in environ:
    virtual_env_dir = environ['VIRTUAL_ENV']
    activate_this = join(virtual_env_dir, "bin", "activate_this.py")
    exec(compile(open(activate_this).read(), activate_this, 'exec'),
         dict(__file__=activate_this))
    virtual_env_name = virtual_env_dir.split(sep)[-1]
    message = 'virtualenv "{0}" ({1})]'.format(virtual_env_name,
                                               virtual_env_dir)
    print(message)
    del virtual_env_dir
del environ, join, sep

Add the following to ~/.config/ipython/profile_default/ipython_config.py:

c.InteractiveShellApp.exec_files = ['ipython_virtualenv.py']

From the IPython FAQ, those with root access can access it by modifying the shebang in /usr/bin/ipython

1
#!/usr/bin/env python

Zsh: Change cursor colour to indicate vi-mode

From Arch Forums.

It’s possible to change the cursor in urxvt when using zsh to indicate the current vi mode (e.g. grey for INSERT, red for NORMAL).

Append the following to ~/.zshrc

33
34
35
36
37
38
39
40
41
42
43
44
45
46
# change cursor colour depending on vi mode
zle-keymap-select () {
  if [ "$TERM" = "rxvt-unicode-256color" ]; then
if [ $KEYMAP = vicmd ]; then
echo -ne "\033]12;red\007"
    else
echo -ne "\033]12;grey\007"
    fi
fi
}; zle -N zle-keymap-select
zle-line-init () {
  zle -K viins
  echo -ne "\033]12;grey\007"
}; zle -N zle-line-init

Zsh auto-detects and sets the editing mode (default: emacs) to vi if $EDITOR=vim. If this environment variable isn’t set, or is set to something else, you’ll also need to add bindkey -v to your ~/.zshrc.

Vim slow on long lines with syntax enabled

Vim is my default text editor. Besides coding, I also use vim with the Hammer plugin to do most my basic word processing.

One major annoyance I’ve found is that terminal vim responds extremely slowly when dealing with files that contain long lines (.e.g. xml, markdown, php, etc.).

Some simple changes in ~/.vimrc to overcome this:

52
53
54
55
" set max syntax columns to prevent lag on long lines (default: 3000)
set synmaxcol=128
" disable cursorline (default: nocursorline)
set nocursorline "

To compensate for loss of the visual aid in the cursorline, in my vim theme and ~/.Xresources, I changed my cursor colour from the default grey/white to yellow.

Git status in zsh prompt – the easy way

Copy the completion file to your home directory:

$ cp /usr/share/git/completion/git-completion.bash ~/.git-completion.bash

Add the following to your ~/.zshrc

75
76
77
78
79
80
81
source ~/.git-completion.bash
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="auto"
PROMPT='%{$fg[cyan]%}%n%{$fg[blue]%}@%{$fg[magenta]%}%m %{$fg[yellow]%}%~ %{$fg[red]%}$(__git_ps1 " (%s)")
%{$fg[green]%}%#%{$reset_color%} '

You may be seeing the following error in your prompt whenever you cd into a local git repository:

local:2: command not found: svn_url_pattern

As discussed here, this is due to syntactical differences between bash and zsh. Make the following changes in ~/.git-completion.bash to fix this:

--- /usr/share/git/completion/git-completion.bash 2012-03-13 10:30:26.000000000 +1100
+++ ./git-completion.bash 2012-03-26 10:22:19.957256527 +1100
@@ -94,8 +94,9 @@ __gitdir ()
__git_ps1_show_upstream ()
{
local key value
- local svn_remote=() svn_url_pattern count n
+ local svn_remote svn_url_pattern count n
local upstream=git legacy="" verbose=""
+ svn_remote=()

# get some config options from git-config
local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\n' '\n ')"
@@ -291,7 +292,7 @@ __git_ps1 ()

if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
- u="%"
+ u="!"
fi
fi