open urxvt here and open in vim applescript
Update: noticed a little bug in the script, the right way to do it should be this:
set disp_no to do shell script "disp_no=($( ps -awx | grep -F 'bin/X' | awk '{print $(NF-2)}' | grep -e \":[0-9]\" )); if [[ -n $disp_no ]];then DISPLAY=${disp_no}.0; else DISPLAY=:0.0; fi;echo $DISPLAY"
if you have tcp forward off, maybe without $NF if it’s enabled but anyway grep -F X11.app won’t work with newer X versions
If you don’t already know I use x11 and a selfcompiled terminal version of vim for all my work. If you’re in OS-X you might still want to run text files in your favorite editor, and have the ability to open the terminal in the current finder version for whatever reason.
I started using Fastscripts Light a long time ago and it’s a pretty nifty little app. The applescript is based a bit on the OpenInTerminal applescript.
However, for some reason when I run the scripts from Fastscripts via hotkey the DISPLAY variable is wrong as follows:
/tmp/launch-9el5tK/:0
I use the following in my shell config files(sorry, it’s not really mine, but I have no idea who I got it from)
# Set the DISPLAY variable -- works for Apple X11 with Fast User Switching if [[ -z $DISPLAY && -z $SSH_CONNECTION ]]; then disp_no=($( ps -awx | grep -F X11.app | awk '{print $NF}' | grep -e ":[0-9]" )) if [[ -n $disp_no ]];then export DISPLAY=${disp_no}.0 else export DISPLAY=:0.0 fi echo "DISPLAY has been set to $DISPLAY" fi
Anyway, the to fix the openinrxvt all you need to do is change it the following way:
disp_no=($( ps -awx | grep -F X11.app | awk '{print $NF}' | grep -e ":[0-9]" ))
if [[ -n $disp_no ]];then
DISPLAY=${disp_no}.0
else
DISPLAY=:0.0
fi
echo $DISPLAY
compressed, the Applescript looks as follows:
set disp_no to do shell script "disp_no=($( ps -awx | grep -F X11.app | awk '{print $NF}' | grep -e \":[0-9]\" )); if [[ -n $disp_no ]];then DISPLAY=${disp_no}.0; else DISPLAY=:0.0; fi;echo $DISPLAY"
do shell script "env DISPLAY=" & disp_no & " /opt/local/bin/urxvt -cd '" & the_path & "' &> /dev/null &"
tell application "X11" to activate
Running vim is pretty much the same except that you will need to compile a console version with the server option, and then run the original instance with—servername VIM (or whatever servername you might want to use).
The relevant launch part of the Applescript looks like this:
do shell script "env DISPLAY=" & disp_no & " /opt/local/vim/bin/vim --remote \"" & the_path & "\" &> /dev/null &"
You can get the complete openinrxvt script here and the run in vim script here
After you place them into your ~/Library/Scripts/Applications/Finder folder you can use Fastscripts:fastscripts to create Finder specific hotkeys.
You might also be interested in a modified version of the script that uses the client/daemon set up of urxvt, which I talked about earlier.
do shell script "env RXVT_SOCKET=$HOME/.rxvt_socket DISPLAY=" & disp_no & " /opt/local/bin/urxvtc -cd '" & the_path & "' &> /dev/null &"
A prettier Terminal in OS-X Part 3 (urxvt and screen)
I was a bit annoyed of having to set TERM=xterm-256color. A more or less proper solution can be found on the rxvt-unicode ml from John Eikenberry.
cd ~ infocmp -L rxvt-unicode > rxvt-unicode.terminfo sed -i '' 's/#256/#32767/' rxvt-unicode.terminfo sed -i '' 's/#88/#256/' rxvt-unicode.terminfo if [ ! -e .terminfo ]; then mkdir .terminfo fi tic -o .terminfo/ rxvt-unicode.terminfo rm rxvt-unicode.terminfo
I’ve also largely assimilated Bart’s configs. You can find them and the screenrc here .
hf
A prettier Terminal in OS-X Part 2 (urxvt and more awesomeness)
PERL=/usr/bin/perl ./configure --foo --bar ...
Update2: you also no longer need the system perl at all along with the double free patch. since my own macosx-clipboard got released with urxvt 9.07 see the changelog here it does depend on Mac-Pasteboard though.
Last time I explained a bit on how to get awesome going. There is a few tuning settings you can do for better awesome usage…
First of all I like the snap font frome the artwiz package for my title bar:
mkdir ~/.fonts wget http://www.flyingseagull.de/blog/assets/artwiz-aleczapka-en-1.3.tar.bz2 tar xjvf artwiz-aleczapka-en-1.3.tar.bz2 mv artwiz-aleczapka-en-1.3/snap.pcf ~/.fonts fc-cache -fv ~/.fonts
Second you might like to have the right apple key as mod and the left one as alt. That way you can have awesome use it’s hotkeys using mod2 and have programs like irssi hook the left apple key as alt while letting your option key work for apostrophes and the like. Note that I use us dvorak as default layout and thus don’t have äöü etc. directly on the keyboard… So YMMV and you might want to adjust the following to your needs. I use the following in my ~/.xmodmap
! left apple key becomes alt ! and right one stays meta clear mod1 clear mod2 keycode 71 = Alt_L add mod2 = Alt_L keycode 63 = Meta_L add mod1 = Meta_L
I have attached my Xdefaults and awesomerc. After disabling the “Enable key equivalents under X11” in Xquartz preferences you can bind awesome keys the way you want them. With my config, leaving X11 would be apple-shift-w. The reason I don’t use Apple-Q is that there is no prompt on exit and in very rare cases the Apple-Q gets passed through from another app you close on top of Xquartz. Apple-W properly closes windows and so on. You should just check the config for the hotkeys.
Oh and don’t forget to do a:
sed -i '' 's/timebomb/YOURUSER/g' ~/.Xdefaults
if you decide to use my Xdefaults.
You should also disable the xterm autolaunch in Xquartz. As the UserFAQ states the following should do the trick:
defaults write org.x.X11 app_to_run /usr/bin/true
Personally I use terminus-font for coding and terminal activity. You can install it with:
sudo port install terminus-font
Again, you might, or might not like it, in which case you will probably like to change your terminals font in the Xdefaults after copying it to ~/.Xdefaults.
Now if you look at my past post, I launch urxvtd in my xinitrc and my awesomerc refers to urxvtc and you might wonder wtf is does, as I did. Well, basically it will just launch one urxvt daemon and many clients. That way the memory usage gets cut down by a lot and the launch times drop a lot too.
Now there is a little issue with urxvt in osx. If you install it through macports it will use macports perl. Why is that such a problem? As far as I know it doesn’t include the obj-c bindings. Which means that you won’t be able to copy and paste without mouse or shift-insert(which wouldn’t be such a problem if we had insert keys on our mac keyboards). I admit there is other ways to handle it, but I settled with the following solution… Basically all you do is compile urxvt with stock perl and patch it.
Before you do the thing below you will probably want to backup ports perl5
#!/bin/sh mv /opt/local/bin/perl5 /opt/local/bin/perl5bak ln -s /usr/bin/perl /opt/local/bin/perl5 wget http://dist.schmorp.de/rxvt-unicode/rxvt-unicode-9.06.tar.bz2 tar xjvf rxvt-unicode-9.06.tar.bz2 cd rxvt-unicode-9.06 patch -p1 < doc/urxvt-8.2-256color.patch patch -p0 < ../rxvtperl-objc-doublefree.diff ./configure --prefix=/opt/local --enable-xterm-colors=256 find . -name Makefile -exec sed -i '' 's/-arch ppc//g' '{}' \; cd src make install cd ../doc make install mv /opt/local/bin/perl5bak /opt/local/bin/perl5
Of course you need to replace ppc with i386 on a g4. Stock perl will make the configure try to build urxvt as universal build and fail (rxvtperl-objc-doublefree.diff is available here).
You might wonder why the double free patch is not included in the distribution of urxvt. Well apparently it’s not that common. I haven’t tried it on other systems, but it seems to be only happening when the objc bridge is loaded in urxvt(i.e. the macosx-clipboard plugin included in urxvt).
Another nice thing I use in urxvt is Barts url-yanking plugin. You can change the hotkeys in the Xdefaults I posted above. Just copy mark-and-yank into ~/.urxvt and you’re set. Basically I can cycle through urls in my console with M-U and launch them in the default browser upon pressing enter…. nifty!