Towards an ideal bash environment.

Feb 07, 2009 01:13

I've been using Linux for over 10 years, however it wasn't until I started getting paid to use Linux on a daily basis that I saw the value in keeping "dot files".

What I want is not a fancy prompt or tweaks to make a self-consistent system. I want to customize my environment so I can do more with less.

I'm still in the idealized design phase of this ( Read more... )

bash, unix, linux

Leave a comment

novas007 February 10 2009, 08:01:01 UTC
  • I've been moving toward something like that… though, with zsh.
    There's a lot going on in my zsh config, but here are some bits i really like:
  • $HOME/.zshrc
    has almost nothing in it.
  • $HOME/.zsh
    has three directories: functions, packages, rc.d.
    • rc.d is the obvious- different files contain different things.
      This part's still in progress, but parts will eventually load conditionally
      on hostname, like here
    • Everything in functions is autoloaded on zsh start, but it's lazy-loaded by this, like:

      mike@hyperion:~> which package
      package () {
      # undefined
      builtin autoload -XUz
      }
      mike@hyperion:~> package
      Couldn't find /home/mike/.zsh/packages/hyperion-
      mike@hyperion:~> which package
      package () {
      export PACKAGEDIR="$HOME/.zsh/packages"
      local package system fn
      package="$1"
      system="$(hostname --fqdn)"

      fn="${PACKAGEDIR}/${system}-${package}"

      if [[ -r $fn ]]; then
      echo "Loading ${system}-${package}"
      . $fn
      else
      echo "Couldn't find $fn"
      fi
      }

Reply

novas007 February 10 2009, 08:01:30 UTC

Resumed since lj limits post sizes. Lame.

  • packages are for software that I need that I don't want in the standard search path. Each file in packages is in a $fqdn-$packagename filename format.
    Here's a pretty good example of my intended use (from .zsh/packages/hyperion-ace):

    path=(/opt/ace/bin $path)
    ldpath=(/opt/ace/lib64 $ldpath)

    pidof Naming_Service &>/dev/null
    if [[ $? -eq 0 ]]; then
    echo "Reusing existing Naming_Service"
    else
    Naming_Service -ORBEndpoint iiop://`hostname`:4900 &
    fi
    export HOSTNAME=`hostname`
    export NameServiceIOR=corbaloc:iiop:1.2@`hostname`:4900/NameService

  • As for actually inhabiting the system, my usual method is to use ssh-copy-id to put my key on, and then get git on the system somehow. It's usually pretty easy (git is basically in C and perl, with only deps on a few perl modules). I then git clone my config-files github repo, and the system is mine :)
  • Most of this would probably work better as a guided tour in screen or on a projector or something, I guess, but I'm starting to get really happy with my setup, so I thought I'd share :)

Reply

novas007 February 10 2009, 09:21:59 UTC

Oh, and one more bit. Since my home dir is in git, I spend pretty much all my time in a git repo. This makes it very useful to know what repo I'm in. I put that info in my zsh RPROMPT:

mike@hyperion:~> cd Personal/mine/phwar (master:mike)
mike@hyperion:~/Personal/mine/phwar> cd VisionWorkbench (master:phwar)
~/Work/projects/VisionWorkbench
mike@hyperion:~/Work/projects/VisionWorkbench> git checkout 2.0_alpha5 (master:VisionWorkbench)
Switched to branch "2.0_alpha5"
mike@hyperion:~/Work/projects/VisionWorkbench> cd (2.0_alpha5:VisionWorkbench)
mike@hyperion:~> (master:mike)

And just to answer the obvious question- yes, zsh's RPROMPT does the right thing:



Reply


Leave a comment

Up