ถ้าผมพิมพ์แล้วมันเสร็จสิ้นไปcat ~/.bashr<TAB>cat ~/.bashrc
ถ้าฉันพิมพ์vim ~/.bashr<TAB>มันจะเสร็จสมบูรณ์เป็นvim /home/neil/.bashrc...
(ทำเช่นเดียวกันกับviซึ่งใช้นามแฝง"vim")
ฉันจะปิดมันได้ไหม?
ถ้าผมพิมพ์แล้วมันเสร็จสิ้นไปcat ~/.bashr<TAB>cat ~/.bashrc
ถ้าฉันพิมพ์vim ~/.bashr<TAB>มันจะเสร็จสมบูรณ์เป็นvim /home/neil/.bashrc...
(ทำเช่นเดียวกันกับviซึ่งใช้นามแฝง"vim")
ฉันจะปิดมันได้ไหม?
คำตอบ:
สิ่งนี้ถูกควบคุมโดย / etc / bash_completion
คุณสามารถคอมเม้นต์รหัสการขยายใน _expand () หากคุณไม่ชอบ
นี่คือเวอร์ชั่นของฉันใน fedora 17 แต่คุณควรจะคล้ายกัน:
# This function expands tildes in pathnames
#
_expand()
{
    # FIXME: Why was this here?
    #[ "$cur" != "${cur%\\}" ] && cur="$cur\\"
    # Expand ~username type directory specifications.  We want to expand
    # ~foo/... to /home/foo/... to avoid problems when $cur starting with
    # a tilde is fed to commands and ending up quoted instead of expanded.
    if [[ "$cur" == \~*/* ]]; then
        eval cur=$cur
    elif [[ "$cur" == \~* ]]; then
        cur=${cur#\~}
        COMPREPLY=( $( compgen -P '~' -u "$cur" ) )
        [ ${#COMPREPLY[@]} -eq 1 ] && eval COMPREPLY[0]=${COMPREPLY[0]}
        return ${#COMPREPLY[@]}
    fi
}function _expand() { :;} ~/.bashrc
                    bashสามารถให้การเติมข้อความอัตโนมัติที่ซับซ้อนยิ่งขึ้นสำหรับคำสั่งบางอย่าง (เช่นข้อโต้แย้งโปรแกรมเติมข้อความอัตโนมัติที่ไม่ใช่ชื่อไฟล์) มีฟังก์ชั่นโปรแกรมเสร็จสมบูรณ์ที่กำหนดไว้สำหรับvimคำสั่งในระบบของคุณ
พิมพ์ดีดที่พร้อมรับคำสั่งจะแสดงสิ่งที่ฟังก์ชั่นที่ใช้ในการจัดให้มีการเติมข้อความอัตโนมัติสำหรับcompletebash
$ complete
complete -o default -F _complete_open openพิมพ์type function_nameเพื่อเรียนรู้เกี่ยวกับคำจำกัดความของพวกเขา
$ type _complete_open
_complete_open is a function
_complete_open () 
{ 
   # function definition
}เพื่อหาฟังก์ชั่นที่ถูกกำหนด ใช้สิ่งต่อไปนี้:
$ shopt -s extdebug
$ declare -F _complete_open
_complete_open 70 /Users/danielbeck/.bash_profile