Permalink
Browse files

commands: use interactive bash shell for load/use aliases and functions

  • Loading branch information...
Karol Będkowski
Karol Będkowski committed Apr 29, 2013
1 parent 21ac421 commit ad9a06472e5628115b42bf24f79dbc14dc8d12be
Showing with 6 additions and 9 deletions.
  1. +6 −9 kupfer/plugin/commands.py
View
@@ -217,14 +217,12 @@ def __init__(self):
TextSource.__init__(self, name=_("Shell Commands"))
# get bash aliases and functions
- bash_cmds = [u'shopt -s expand_aliases', u'source /etc/bash.bashrc']
- bashrc_path = u'%s/.bashrc' % (format(os.path.expanduser(u'~')),)
- bash_cmds.append(u' '.join((u'source', quote(bashrc_path))))
- self._bash_cmds = bash_cmds = u';'.join(bash_cmds) + '\n'
-
+ bash_cmds = [u'shopt -s expand_aliases', u'source /etc/bash.bashrc',
+ u'source ' + quote(format(os.path.expanduser(u'~/.bashrc')))]
+ self._bash_cmds = bash_cmds = u';'.join(bash_cmds) + ";"
# get alias names
try:
- lines = check_output(('bash', '-c', bash_cmds + u'alias'))
+ lines = check_output(('bash', '-i', '-c', bash_cmds + u'alias'))
except OSError:
# no bash
pass
@@ -237,10 +235,9 @@ def __init__(self):
if word and '=' in word:
# reduce to name
aliases.append(word[:word.find('=')])
-
# get function names
try:
- lines = check_output(('bash', '-c', bash_cmds + u'declare -F'))
+ lines = check_output(('bash', '-i', '-c', bash_cmds + u'declare -F'))
except OSError:
# no bash
pass
@@ -276,7 +273,7 @@ def get_text_items(self, text):
if (__kupfer_settings__["aliases"] and firstword in self._aliases) or \
(__kupfer_settings__["functions"] and firstword in self._fns):
cmds = self._bash_cmds + u" ".join(firstwords)
- yield BashCommand(u'bash -c %s' % quote(cmds), text)
+ yield BashCommand('bash -i -c '+ quote(cmds), text)
# iterate over $PATH directories
PATH = os.environ.get("PATH", os.defpath)
for execdir in PATH.split(os.pathsep):

0 comments on commit ad9a064

Please sign in to comment.