cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.87k stars 177 forks source link

Command 'add' not found #94

Closed goddade closed 4 years ago

goddade commented 4 years ago

Ubuntu 18.04 bash Every time I enter a command, it will show:

.../mcfly$ ls
Cargo.lock  CHANGELOG.txt  dev.bash  docs             LICENSE     mcfly.zsh  README.md  target
Cargo.toml  ci             dev.zsh   HomebrewFormula  mcfly.bash  pkg        src

Command 'add' not found, did you mean:

  command 'amd' from deb am-utils
  command 'dd' from deb coreutils
  command 'tdd' from deb devtodo
  command 'aid' from deb id-utils
  command 'pdd' from deb pdd
  command 'axd' from deb afnix
  command 'ldd' from deb libc-bin
  command 'and' from deb and
  command 'dad' from deb debian-dad
  command 'adbd' from deb android-tools-adbd
  command 'ad' from deb netatalk
  command 'ddd' from deb ddd
  command 'adb' from deb adb
  command 'atd' from deb at

Try: sudo apt install <deb name>
cantino commented 4 years ago

I've never seen this before. Can you show me the bash code that you added to your .bashrc file?

goddade commented 4 years ago

.bashrc file:

# mcfly
if [[ -f ~/.mcfly/mcfly.bash ]]; then
  source ~/.mcfly/mcfly.bash
fi

In the mcfly.bash file, I modified the last few lines:

# if [[ $- =~ .*i.* ]]; then
#   if set -o | grep "vi " | grep -q on; then
#     bind "'\C-r': '\e0i#mcfly: \e\C-j mcfly search\C-j'"
#   else
#     bind "'\C-r': '\C-amcfly: \e# mcfly search\C-j'"
#   fi
# fi
bind "'\C-r': '\e0i#mcfly: \e\C-j mcfly search\C-j'"
goddade commented 4 years ago

The problem is in the mcfly.bash file.

  # Run mcfly with the saved code. It will:
  # * append commands to $HISTFILE, (~/.bash_history by default)
  #   for backwards compatibility and to load in new terminal sessions;
  # * find the text of the last command in $MCFLY_HISTORY and save it to the database.
  $MCFLY_PATH add --exit ${exit_code} --append-to-histfile

$MCFLY_PATH is empty.

cantino commented 4 years ago

mcfly.bash sets MCFLY_PATH to MCFLY_PATH=${MCFLY_PATH:-$(which mcfly)}. Does which mcfly not return a valid path to the binary for you?

goddade commented 4 years ago

I found the cause of the problem. The rust environment variable has not been added when sourcing mcfly.bash.

cantino commented 4 years ago

Is there anything we should add to mcfly.bash to help prevent this?

goddade commented 4 years ago

I think it should provide a useful error message when MCFLY_PATH is empty.

if [ -z "$MCFLY_PATH" ]; then
    echo "Cannot find mcfly, please make sure you have added the rust environment variable before sourcing mcfly.bash."
fi
cantino commented 4 years ago

Great idea. Added in 5e3161d.