return to OCLUG Web Site
A Django site.
February 25, 2010

Bart Trojanowski
jukie
Bart's Blog
» pimped out zsh prompt

Here is yet another update to the series. I've updated my git prompt again, now using the zsh 4.3.7 built in vcs_info module. This time the motivation came from Zsh Prompt Magic article. Here is what it looks like now:

zsh git prompt

Everything is now self contained in one file: S60_prompt. Grab it and source it into your zsh config.

The features are:

  • name of current branch,
  • git repo state (rebase, am, bisect, merge, etc),
  • markers indicating staged/unstaged changes,
    • little 1 after branch name indicates dirty working tree,
    • little 2 after branch name indicates staged changes,
  • highlight depth decended into the repository on the right,
  • show failure of commands via prompt background change,
  • show command/insert mode when using vi mode (set -o vi).

[Read More]

February 22, 2010

Bart Trojanowski
jukie
Bart's Blog
» live termcasting of your terminal over telnet

I mentioned earlier that I will be giving a talk at Flourish Conf next month. While preparing for the talk I decided to I wanted to share my terminal with the participants of the Workshop via telnet. The more popular alternative would be to use screen built in sharing, or maybe vnc, which would require more memory and CPU overhead... and additional accounts using the former method. I only have a SheevaPlug to work with, so I am trying to be as conservative as possible.

[Read More]

January 16, 2010

Bart Trojanowski
jukie
Bart's Blog
» running really nice

Everyone that uses the shell eventually learns about nice -- the tool that runs a process at a reduced priority. Well, there is also ionice that allows you to tweak processes from taking over all disk IO.

I added a vnice() function into my ZSH config so I can run or mark processes for lower priority for both nice and ionice levels.

[Read More]

June 30, 2009

Pythian
pythian
» Windows PowerShell for the SQL Server DBA

Most people think Windows administrators make a living with their right-hand—you know, right-clicking and left-clicking the user interface to get things done. While anybody can do that in Windows, the real value comes in when you no longer need to rely so much on the user interface but instead write scripts. Lower total cost of ownership is achieved when the administrative costs are kept low, and this is where Windows PowerShell comes in.

I’ve spent a fair amount of time writing VBScript scripts to administer Windows servers and workstations and automating repetitive tasks. One reason for me moving into Windows PowerShell is its roots in the Microsoft .NET Framework, as I have done a fair amount of .NET programming. But what is Windows PowerShell anyway?

Windows PowerShell is an extensible command-line shell and an associated scripting language built on top of the .NET Framework v2.0. It was released in 2006 and is currently available for Windows XP SP2/SP3, Windows Server 2003, Windows Vista, and is included in Windows Server 2008.

PowerShell will be included as a common engineering criteria (CEC) in future releases of Microsoft server products, making it a must-learn for Microsoft server administrators.

Administrators (DBAs included) have been using scripting to automate administrative tasks with scripting languages like DOS batch, VBScript, Perl, and a few third-party tools like KiXtart and WinScript. Windows PowerShell complements the administrators’ existing scripting toolkit to easily manage and administer Windows workstations and servers and other Microsoft server products as THEY are being built using the .NET Framework.

Although it is designed for operating systems, Windows PowerShell can be used to administer SQL Server 2005 instances and higher, as Server Management Objects—the object model used to manage SQL Server 2005—are built using the .NET Framework, thus exposing the object model in PowerShell. And since SMO is compatible with SQL Server 2000, you can administer SQL Server 2000 instances using Windows PowerShell. SQL Server 2008 even ships with its own PowerShell snap-in.

No wonder it makes sense to learn a thing or two about Windows PowerShell. Besides, I’ve seen Windows administrators being “forced” to do SQL Server DBA tasks even without knowing what T-SQL is. Windows PowerShell makes it a level playing field.

I will be posting a series of blog posts on getting started with Windows PowerShell, and how any Windows administrator can use it for their day-to-day tasks. In the process, I’ll also cover how to use Windows PowerShell for administering SQL Server instances.

June 10, 2009

Bart Trojanowski
jukie
Bart's Blog
» how would you read a file into an array of lines

I was working on a shell script that needed to look at some lines in a bunch of files and perform some data mining. I started it in bash, so I am writing it in bash even though dave0 notes that I should have started in in perl. Point taken... I suffer for my mistake.

After a quick google I learned that a nice way to do what the topic of this post describes can be done using

    IFS='
    '
    declare -a foo=( $(cat $file) )

Which is great! Right?

[Read More]

May 31, 2009

Bart Trojanowski
jukie
Bart's Blog
» mark-yank-urls: fix bug allowing shell to interpret the url

I committed a fix for an annoying bug in the urxvt mark-yank-urls script.

This has been reported by several people. I have finally fixed it, but the credit should go to Hans Dieter Pearcey, Daniel Danner and Olof Johansson for reporting it.

May 4, 2009

Bart Trojanowski
jukie
Bart's Blog
» two terminals one PWD

I often find myself needing multiple terminals (urxvt) with shells (zsh) in the same directory. The step of entering that directory is teadieous, especially if there are many terminals involved. I have a few tricks that I use to make this faster.

[Read More]

April 6, 2009

Dave O'Neill
dmo
blog
» How to detect virtualization

Frequently, our customers want to install our software in a virtual machine. This can be OK, but frequently they hit a CPU, memory, or IO limit caused by running in a constrained virtual environment. When this happens, we really like to know if they're running under virtualization when we try to support them. Here's some tricks to detect, from a shell, if the system is virtualized.

[Read More]

March 21, 2009

Bart Trojanowski
jukie
Bart's Blog
» shrinking URLs

I wrote a short script to shrink URLs:

    % shorturl http://www.jukie.net/~bart/shorturl
    http://2tu.us/ce8

    % shorturl
    Type in some urls and I'll try to shrink them for you...
    http://www.jukie.net/~bart/shorturl
    http://2tu.us/ce8
    http://www.jukie.net/~bart/20090320214228
    http://2tu.us/ce9

I am doing this as part of my new identi.ca addiction^W usage and extending GregKH's command line micro blogging tool.

March 4, 2009

Bart Trojanowski
jukie
Bart's Blog
» readlater

Instapaper is a quick way to stash things to read later. Here is a script that lets you post from the command line: readlater.

    $ readlater http://www.jukie.net/
    This URL has been successfully added to this Instapaper account.

Don't forget to fill in the USER and PASS fields in the script :)

Next, I wanted to call on this from vimperator. I wrote this vimpeator plugin to do that.

May 30, 2008

Dave O'Neill
dmo
blog
» How to detect virtualization

Frequently, our customers want to install our software in a virtual machine. This can be OK, but frequently they hit a CPU, memory, or IO limit caused by running in a constrained virtual environment. When this happens, we really like to know if they're running under virtualization when we try to support them. Here's some tricks to detect, from a shell, if the system is virtualized.

more

May 10, 2008

Bart Trojanowski
jukie
Bart's Blog
» show current git branch on zsh prompt (2)

NOTE: This post has been updated (again).

I previously wrote about showing the git branch name on the zsh prompt. Caio Marcelo pointed out that it didn't work very well because the git branch was being queried before the command was executed, and it should be after to catch git commands that change the branch, like git branch and git checkout.

He was right, here is a repost.

[Read More]

May 9, 2008

Bart Trojanowski
jukie
Bart's Blog
» show more git info on zsh prompt

This is my third post on the topic. I have harshly assimulated MadCoder's configuration. Here is my new zsh prompt:

zsh git prompt

[Read More]

March 21, 2008

Pythian
pythian
» Saying What You Mean

Ah, the perils of working in a shared, client environment. One client has us using a login that is not exclusive to us. I prefer using bash; the client is set to use zsh. This is not a problem in and of itself.

However, there is a section in the .profile that is causing me issues:

if [ -f /usr/bin/ksh ]; then
        /usr/bin/ksh -o vi
        exit
fi

So, “If ksh exists, run it with some options to edit history with vi-like commands”. Except what we really want is “If you’re using the ksh as a shell, . . . .”

So I added a modification, and now all is fine.

if [ -f /usr/bin/ksh ]; then
        if [ "$SHELL" = "/usr/bin/ksh" ]; then
                /usr/bin/ksh -o vi
                exit
        fi
fi

(not all my problems are MySQL related!)