On Wed, December 14, 2005 8:13 am, Harshad wrote:
> Axel Liljencrantz wrote:
>
>> On Tue, 13 Dec 2005, Harshad wrote:
>>
>>> I have this function _show_listing that shows the directory contents
>>> whenever I change my working directory.
>>>
>>> I have defined it as
>>> function -v PWD _show_listing
>>> blah blah
>>> end
>>>
>>> But this function is getting executed whenever I press <TAB> for
>>> completion of a filename. Is there a better way to get this
>>> functionality?
>>
>> Sure. You can test if the running code is in a command substitution
>> using something like:
>>
>> function -v PWD _show_listing
>> if status --is-command-substitution
>> return
>> end
>> blah blah
>> end
>
> Now it is always returning, without executing blah blah.
Silly me. An event handler is a command substitution, so that will always
evaulate to true.
Ok, new approach. Lets' define a cd function. The trouble here is that a
cd wrapper function is already defined, doing things with the directory
history. So we redefine it as __cd_wrapper. Something like this:
eval (functions cd|sed -e 's/function cd/function __cd_wrapper/')\n
function cd
__cd_wrapper $argv
if status --is-command-substitution
return
end
blah blah blah
end
A bit of a hack, but it could be worse.
>
>>
>>
>>>
>>> Zsh has a function called chpwd() that gets called whenever the working
>>> directory gets changed (from the user's point of view). Can something
>>> similar be defined for fish?
>>>
>> k
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> Fish-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users