[dev] dmenu: patch for including bash aliases

From: Samee Zahur <samee.zahur_AT_gmail.com>
Date: Sun, 9 Jun 2013 23:04:58 -0400

Thought this would be useful for bash alias lovers with lots of
shortcuts in their ~/.bashrc or ~/.bash_aliases (path defined in the
$aliases variable below).

Cheers!

--Samee


-#!/bin/sh
+#!/bin/bash
 cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
 if [ -d "$cachedir" ]; then
  cache=$cachedir/dmenu_run
 else
  cache=$HOME/.dmenu_cache # if no xdg dir, fall back to dotfile in ~
 fi
-(
+cmd=`(
  IFS=:
- if stest -dqr -n "$cache" $PATH; then
- stest -flx $PATH | sort -u | tee "$cache" | dmenu "$_AT_"
+ aliases=~/.bashrc
+ if stest -dqr -n "$cache" $PATH || stest -fqr -n "$cache" "$aliases"; then
+ (
+ stest -flx $PATH
+ source $aliases
+ alias | sed 's/alias \([[:alnum:]]\+\)=.*/\1/'
+ ) | sort -u | tee "$cache" | dmenu "$_AT_"
  else
  dmenu "$_AT_" < "$cache"
  fi
-) | ${SHELL:-"/bin/sh"} &
+)`
+# Perform alias expansion on $cmd
+echo -e "source ~/.bashrc \n $cmd" | bash -O expand_aliases &
Received on Mon Jun 10 2013 - 05:04:58 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 10 2013 - 05:12:05 CEST