Tag: bash

  • Execute code if a script directly called

    I often want to run some arbitrary code if I run a script directly. The primary example that comes to mind these days is: Strangely enough, despite primarily using Ruby on a daily basis, I haven’t really thought about how this test looks in Ruby: Bash seemed a little more obvious, but apparently there’s a…

  • Using Escape Codes and Setting Window Title on PS1 for ksh (Korn Shell)

    I set up the following in my ~/.profile for my ksh login: export HOST=$(hostname) export PS1=$(perl -e ‘printf “33]0;${USER}@${HOST}:${PWD}07$”‘) Unfortunately, ksh doesn’t understand escape codes, so perl or awk is necessary to pull this off–or you can enter them literally via your editor. I like the perl route just for ease of maintenance. This was…