Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Slight issue with enable-plugin #136

Closed
ajy opened this Issue · 7 comments

3 participants

@ajy

Hey, just pulled your recent changes, that created the enable-plugin command, which doesn't seem to be working right.
Every plugin i try to enable with it seems to get an incorrect symlink. "?[0m" gets appended to the name of the file in the enabled directory.
Plugins i've tried with it are git, dirs, fasd, tmux, ssh

@tswicegood
Owner

Paging @erichs (since he's the one who implemented this).

@AjayGavankar What is your $TERM variable set to? I just disabled and re-enabled dirs on my system with no problem.

@erichs
Owner

Interesting. For reference, here's the code in question:

    if [ "$1" = "all" ]; then
        typeset f plugin;
        for f in $BASH_IT/plugins/available/*.bash;
        do
            plugin=$(basename $f);
            if [ ! -h $BASH_IT/plugins/enabled/$plugin ]; then
                ln -s $BASH_IT/plugins/available/$plugin $BASH_IT/plugins/enabled/$plugin;
            fi;
        done;
    else
        typeset plugin=$(ls $BASH_IT/plugins/available/$1.*bash 2>/dev/null | head -1);
        if [ -z "$plugin" ]; then
            printf '%s\n' 'sorry, that does not appear to be an available plugin.';
            return;
        fi;
        plugin=$(basename $plugin);
        if [ -e $BASH_IT/plugins/enabled/$plugin ]; then
            printf '%s\n' "$1 is already enabled.";
            return;
        fi;
        ln -s $BASH_IT/plugins/available/$plugin $BASH_IT/plugins/enabled/$plugin;
    fi;

@AjayGavankar, when you do this:

target=git
plugin=$(ls $BASH_IT/plugins/available/$target.*bash 2>/dev/null | head -1)
echo "XXX${plugin}XXX"

what do you see?

@ajy

thanks for the quick reply
@tswicegood my $TERM is set to xterm
@erichs running your code gives me this-
"XXX/home/my_username/.bash_it/plugins/available/git.plugin.bashXXX"

have tried more stuff, enabling all plugins works perfectly, except for the clash between fasd and z.

and inserting these statements

echo $plugin
echo $BASH_IT/plugins/available/$plugin
echo $BASH_IT/plugins/enabled/$plugin

just before the ln command gives this when i try to enable dirs

dirs.plugin.bash
/home/my_username/.bash_it/plugins/available/dirs.plugin.bash
/home/my_username/.bash_it/plugins/enabled/dirs.plugin.bash

which looks right, so i'm guessing the ln command is screwing up somehow, but typing out the ln command in the terminal creates the symlink perfectly and enables the plugin.

weirdest thing i have ever seen

@erichs
Owner

Assuming you've tried closing your terminal and re-opening it?

"?[0m" is likely an ANSI escape sequence gone astray. What theme and prompt code are you using?

Also, what happens if you:

$ rm -rf $BASH_IT/plugins/enabled
$ mkdir $BASH_IT/plugins/enabled
$ enable-plugin base
$ ls -l $BASH_IT/plugins/enabled
@ajy

yeah tried closing the terminal and re-opening it.
I'm using the zork theme.
The output of those commands is:
total 0
lrwxrwxrwx 1 aj aj 56 May 20 12:15 "base.plugin.bash?[0m" -> "/home/aj/.bash_it/plugins/available/base.plugin.bash?[0m"

with the things in quotes getting highlighted red in my solarized terminal, which i think means the symlink is broken

@erichs
Owner

Ok, thanks!

Try changing your theme. Does that help?

Try replacing this line:

typeset plugin=$(ls $BASH_IT/plugins/available/$1.*bash 2>/dev/null | head -1)

with this:

typeset plugin=$(ls $BASH_IT/plugins/available/$1.plugin.bash 2>/dev/null | head -1)

does that work?

If not, try replacing it with this:

typeset plugin=$(command ls $BASH_IT/plugins/available/$1.*bash 2>/dev/null | head -1)

If any of those suggestions fix your issue, I'd like to know which.

@ajy

Hey, thanks for figuring it out, the last one did the trick .i.e.

typeset plugin=$(command ls $BASH_IT/plugins/available/$1.*bash 2>/dev/null | head -1)

Works for all the plugins above that didn't work before

@ajy ajy closed this
@erichs erichs referenced this issue from a commit in erichs/bash-it
@erichs erichs fix for issue #136
issue #136 was found to be caused by an aliased 'ls' command that
generated rogue values for 'plugin' in the enable/disable-plugin()
functions. this commit fixes that by forcing the shell to disregard
aliased 'ls' commands.
bffae2a
@obitum obitum referenced this issue from a commit in obitum/bash-it
@erichs erichs fix for issue #136
issue #136 was found to be caused by an aliased 'ls' command that
generated rogue values for 'plugin' in the enable/disable-plugin()
functions. this commit fixes that by forcing the shell to disregard
aliased 'ls' commands.
c7207cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.