sudo: fastboot: command not found ,fastboot自动补全,adb自动补全

使用fastboot时提示 sudo: fastboot: command not found 必须输入完整的命令路径才行,使用起来很麻烦,所以

可以使用下面的方法解决:

le@u:~$ sudo ln -s /home/le/Android/Sdk/platform-tools/fastboot /usr/local/sbin/fastboot
le@u:~$ sudo ln -s /home/le/Android/Sdk/platform-tools/adb /usr/local/sbin/adb

红色部分为fastboot命令路径,需根据实际安装路径确定。

使用fastboot,adb时,如果想使用tab键自动补全命令,可将以下文本复制保存为文件名为fastboot的文件然后放在 /etc/bash_completion.d/目录下

文件名:fastboot

#!/bin/sh
_fastboot()  
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="reboot boot flash devices -w reboot-bootloader"


    case "$prev" in
    reboot | devices | -w | reboot-bootloader)
        COMPREPLY=()
        return 0
        ;;
    flash)
        COMPREPLY=( $(compgen -W "boot system recovery radio userdata rpm sbl1 modem tz persist splash aboot" -- $cur ))
        return 0
        ;;
    boot)
        COMPREPLY=( $(compgen -o filenames -G "${cur}*.img"))
        return 0
        ;;
    *)
        local prev2="${COMP_WORDS[COMP_CWORD-2]}"
        local prev3="${COMP_WORDS[COMP_CWORD-3]}"
        if [ "$prev2" == "flash" ];then
            COMPREPLY=( $(compgen -o filenames -G "${cur}*.img"))
            return 0
        elif [ "$prev2" == "boot" ];then
            COMPREPLY=()
            return 0
        elif [ "$prev3" == "flash" ];then
            COMPREPLY=()
            return 0
        fi
        ;;
    esac


    COMPREPLY=( $(compgen -W "$opts" -- $cur) )
    return 0
}
complete -F _fastboot fastboot 

adb自动补全,更为完整的实现请参考  S5林风 的博客
文件名:adb (同样放在 /etc/bash_completion.d/ 目录下)

#!/bin/sh
_adb()  
{
    local cur prev opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="shell push pull reboot reboot-bootloader forward logcat devices kill-server root remount"


    case "$prev" in
    shell | pull | reboot-bootloader | logcat | devices | kill-server | root | remount)
        COMPREPLY=()
        return 0
        ;;
    reboot)
        COMPREPLY=( $(compgen -W "bootloader recovery" -- $cur) )
        return 0
        ;;
    push)
        COMPREPLY=( $(compgen -o default -o plusdirs -f -- $cur) )
        return 0
        ;;
    *)
        local prev2="${COMP_WORDS[COMP_CWORD-2]}"
        if [ "$prev2" == "push" ] || [ "$prev2" == "reboot" ];then
            return 0
        fi
        ;;
    esac	


    COMPREPLY=( $(compgen -W "$opts" -- $cur) )
    return 0
}
complete -F _adb adb





你可能感兴趣的:(Android,android,fastboot,adb)