Alright, it's late and I'm in lazy-hack mode, so there's likely a
better way to do this, that's left up to the reader :).  I think I've
got it working, but it requires editing
/usr/share/awesome/lib/awful/completion.lua.  Patch is attached.

I've only updated it for bash, because I have no experience with zsh;
and I've only tested the "compgen -A command" path as I'm just using
vanilla bash completion.

Hope it works for you!

Cheers,
Bryan


On Wed, 13 Jun 2012 11:40:56 +0200
"Emilio J. Padron" <[email protected]> wrote:

> Hi there!
> 
> Any simple (and smart) way of having your shell aliases (I have mine
> in a separate file .bash_aliases) working with the run function
> executed by mod+r?
> 
> I have had a look at the mailing list's history, but I have not found
> a satisfactory solution :-/ (even though I have read messages about
> this matter).
> 
> I have tried all kind of combos with my *rc files and stuff such as
>       . ~/bash_aliases
>       shopt -s expand_aliases
> with no success :-/
> 
> Thanks!
> E
> 

--- completion.lua.original	2012-05-21 00:06:04.000000000 -0700
+++ completion.lua	2012-06-14 00:01:51.459631138 -0700
@@ -106,14 +106,17 @@
     else
         if bashcomp_funcs[words[1]] then
             -- fairly complex command with inline bash script to get the possible completions
-            shell_cmd = "/usr/bin/env bash -c 'source " .. bashcomp_src .. "; " ..
+            shell_cmd = "/usr/bin/env bash -c '(source " .. bashcomp_src .. "; " ..
             "__print_completions() { for ((i=0;i<${#COMPREPLY[*]};i++)); do echo ${COMPREPLY[i]}; done }; " ..
             "COMP_WORDS=(" ..  command .."); COMP_LINE=\"" .. command .. "\"; " ..
             "COMP_COUNT=" .. cur_pos ..  "; COMP_CWORD=" .. cword_index-1 .. "; " ..
-            bashcomp_funcs[words[1]] .. "; __print_completions'"
+            bashcomp_funcs[words[1]] .. "; __print_completions"
         else
-            shell_cmd = "/usr/bin/env bash -c 'compgen -A " .. comptype .. " " .. words[cword_index] .. "'"
+            shell_cmd = "/usr/bin/env bash -c '(compgen -A " .. comptype .. " " .. words[cword_index]
         end
+	-- Also source aliases from .bashrc and search them.
+	shell_cmd = shell_cmd .. "; source $HOME/.bashrc"
+	shell_cmd = shell_cmd .. "; alias | cut -d\\  -f2 | sed s/=.\\*// | while read X; do [[ $X = " .. words[cword_index] .. "* ]] && echo $X; done) | sort'"
     end
     local c, err = io.popen(shell_cmd .. " | sort -u")
     local output = {}

Reply via email to