[solved] tab completion on bash alias

Hello everybody,
I got my install up and running .
But now I am trying to improbe productivity by adding a simple command:
cd %1 && ls
I got it working by making it like this:
cc () {
cd $* && ls
This works exactly as I want it. But it doesn`t have tab completion!
Is it possible to enable this?
(if I change the function name to cd it does have tab completion but it goes in an endless loop, learnt that the hard way)
Last edited by gnur (2008-11-07 15:40:55)

I think i should have been more clear.
I meant the completion wasn't working for the folder names.
So cc /ho<tab> won't give me home, it doesn't do anything at all.
//edit: it seems that restarting X gave me they joy of it working.
Last edited by gnur (2008-11-07 15:40:07)

Similar Messages

  • [SOLVED] Using arguments in Bash Alias

    Hi all!
    I'm not very well-versed in the  art of bash scripting or anything and I am having some trouble doing an alias that uses two arguments.
    My case:
    My command:
    "openssl aes-256-cbc -a -salt -in a.txt -out a.txt.aes"
    What I wanted to do was an alias like this:
    alias encrypt="openssl aes-256-cbc -a -salt -in $1 -out $2"
    But it's not working. Actually, even using just the $1 and leaving a fixed string as $2 is not working.
    Can anyone give me some help? Thanks!
    Last edited by Wasser (2012-05-09 22:45:56)

    karol wrote:Aliases simply don't take arguments, functions do (just like the mathematical functions).
    Well, though one can of course use arguments with aliases, e.g.
    alias p='sudo pacman'
    still allows you do specify options, etc of course, such as:
    p -Syu foobar
    Might be "better"/less confusing to say that an alias is just a simple string replacement, and for more "complicated" things one needs indeed to e.g. use a function.

  • [SOLVED]mplayer tab completion with *.divx files

    Hi,
    I have some *.divx files. mplayer plays them fine, but the tab completion in bash doesn't work. So I'll either have to type the filename or do something like vim <filename>, go back and write mplayer instead of vim. That's getting pretty annoying, so I hope someone can help me
    Last edited by rine (2008-09-17 00:02:47)

    I assume you use the bash_completition script.
    The easy way is to rename the file to the actual container (avi, mkv, mp4, wmv, whatever)
    The hard way is to patch bash_completition:
    you should add the extensions you like to line 5895: for example
    _filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fli|FLI|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mkv|MKV|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|divx)'

  • SVN Tab Complete issues (space after each complete)

    Morning all,
    I've got a weird issue with my SVN tab complete using Bash, it adds a space after each item it completes - for example: Say there is a directory 'foobar' with a file 'zomg' within that, I'd type 'svn add fo' and then hit tab - however, this results in 'svn add foobar ' (note the space). This is highly annoying, as I can no longer hit 'z' then tab to complete it to 'foobar/zomg', I have to remove the space, then go again (it does it for everything, so adding something like 'foobar/zomg/wtf/bbq' is a nightmare.)
    So far it only does it with Bash, I've not been able to test it on other shells. Subversion 1.4.6-4 on an up-to-date Arch install with core, extra and community repos enabled (however it has done it from the very start of me using Arch, so it's not a recent update that killed it).
    Regards,
    Last edited by AlexC_ (2008-09-20 16:13:48)

    Hi AlexC_ :-)
    I suspect that it may be an issue with /etc/bash_completion. This is the relevant part from my /etc/bash_completion.
    # svn completion
    have svn &&
    _svn()
    local cur prev commands options command
    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    commands='add blame praise annotate ann cat checkout co cleanup commit \
    ci copy cp delete del remove rm diff di export help ? h import \
    info list ls lock log merge mkdir move mv rename ren \
    propdel pdel pd propedit pedit pe propget pget pg \
    proplist plist pl propset pset ps resolved revert \
    status stat st switch sw unlock update up'
    if [[ $COMP_CWORD -eq 1 ]] ; then
    if [[ "$cur" == -* ]]; then
    COMPREPLY=( $( compgen -W '--version' -- $cur ) )
    else
    COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
    fi
    else
    prev=${COMP_WORDS[COMP_CWORD-1]}
    case $prev in
    --config-dir)
    _filedir -d
    return 0;
    -@(F|-file|-targets))
    _filedir
    return 0;
    --encoding)
    COMPREPLY=( $( compgen -W \
    '$( iconv --list | sed -e "s@//@@;" )' \
    -- "$cur" ) )
    return 0;
    --@(editor|diff|diff3)-cmd)
    COMP_WORDS=(COMP_WORDS[0] $cur)
    COMP_CWORD=1
    _command
    return 0;
    esac
    command=${COMP_WORDS[1]}
    if [[ "$cur" == -* ]]; then
    # possible options for the command
    case $command in
    add)
    options='--auto-props --no-auto-props \
    --force --targets --no-ignore \
    --non-recursive -N -q --quiet'
    @(blame|annotate|ann|praise))
    options='-r --revisions --username \
    --password --no-auth-cache \
    --non-interactive -v \
    --verbose --incremental --xml'
    cat)
    options='-r --revision --username \
    --password --no-auth-cache \
    --non-interactive'
    @(checkout|co))
    options='-r --revision -q --quiet -N \
    --non-recursive --username \
    --password --no-auth-cache \
    --non-interactive \
    --ignore-externals'
    cleanup)
    options='--diff3-cmd'
    @(commit|ci))
    options='-m --message -F --file \
    --encoding --force-log -q \
    --quiet --non-recursive -N \
    --targets --editor-cmd \
    --username --password \
    --no-auth-cache \
    --non-interactive --no-unlock'
    @(copy|cp))
    options='-m --message -F --file \
    --encoding --force-log -r \
    --revision -q --quiet \
    --editor-cmd -username \
    --password --no-auth-cache \
    --non-interactive'
    @(delete|del|remove|rm))
    options='--force -m --message -F \
    --file --encoding --force-log \
    -q --quiet --targets \
    --editor-cmd -username \
    --password --no-auth-cache \
    --non-interactive'
    @(diff|di))
    options='-r --revision -x --extensions \
    --diff-cmd --no-diff-deleted \
    -N --non-recursive --username \
    --password --no-auth-cache \
    --non-interactive --force \
    --old --new --notice-ancestry'
    export)
    options='-r --revision -q --quiet \
    --username --password \
    --no-auth-cache \
    --non-interactive -N \
    --non-recursive --force \
    --native-eol --ignore-externals'
    import)
    options='--auto-props --no-auto-props \
    -m --message -F --file \
    --encoding --force-log -q \
    --quiet --non-recursive \
    --no-ignore --editor-cmd \
    --username --password \
    --no-auth-cache \
    --non-interactive'
    info)
    options='--username --password \
    --no-auth-cache \
    --non-interactive -r \
    --revision --xml --targets \
    -R --recursive --incremental'
    @(list|ls))
    options='-r --revision -v --verbose -R \
    --recursive --username \
    --password --no-auth-cache \
    --non-interactive \
    --incremental --xml'
    lock)
    options='-m --message -F --file \
    --encoding --force-log \
    --targets --force --username \
    --password --no-auth-cache \
    --non-interactive'
    log)
    options='-r --revision -v --verbose \
    --targets --username \
    --password --no-auth-cache \
    --non-interactive \
    --stop-on-copy --incremental \
    --xml -q --quiet --limit'
    merge)
    options='-r --revision -N \
    --non-recursive -q --quiet \
    --force --dry-run --diff3-cmd \
    --username --password \
    --no-auth-cache \
    --non-interactive \
    --ignore-ancestry'
    mkdir)
    options='-m --message -F --file \
    --encoding --force-log -q \
    --quiet --editor-cmd \
    --username --password \
    --no-auth-cache \
    --non-interactive'
    @(move|mv|rename|ren))
    options='-m --message -F --file \
    --encoding --force-log -r \
    --revision -q --quiet \
    --force --editor-cmd \
    --username --password \
    --no-auth-cache \
    --non-interactive'
    @(propdel|pdel|pd))
    options='-q --quiet -R --recursive -r \
    --revision --revprop \
    --username --password \
    --no-auth-cache \
    --non-interactive'
    @(propedit|pedit|pe))
    options='-r --revision --revprop \
    --encoding --editor-cmd \
    --username --password \
    --no-auth-cache \
    --non-interactive --force'
    @(propget|pget|pg))
    options='-R --recursive -r --revision \
    --revprop --strict --username \
    --password --no-auth-cache \
    --non-interactive'
    @(proplist|plist|pl))
    options='-v --verbose -R --recursive \
    -r --revision --revprop -q \
    --quiet --username --password \
    --no-auth-cache \
    --non-interactive'
    @(propset|pset|ps))
    options='-F --file -q --quiet \
    --targets -R --recursive \
    --revprop --encoding \
    --username --password \
    --no-auth-cache \
    --non-interactive -r \
    --revision --force'
    resolved)
    options='--targets -R --recursive -q \
    --quiet'
    revert)
    options='--targets -R --recursive -q \
    --quiet'
    @(status|stat|st))
    options='-u --show-updates -v \
    --verbose -N --non-recursive \
    -q --quiet --username \
    --password --no-auth-cache \
    --non-interactive --no-ignore \
    --ignore-externals \
    --incremental --xml'
    @(switch|sw))
    options='--relocate -r --revision -N \
    --non-recursive -q --quiet \
    --username --password \
    --no-auth-cache \
    --non-interactive --diff3-cmd'
    unlock)
    options='--targets --force --username \
    --password --no-auth-cache \
    --non-interactive'
    @(update|up))
    options='-r --revision -N \
    --non-recursive -q --quiet \
    --username --password \
    --no-auth-cache \
    --non-interactive \
    --diff3-cmd --ignore-externals'
    esac
    options="$options --help -h --config-dir"
    COMPREPLY=( $( compgen -W "$options" -- $cur ) )
    else
    if [[ "$command" == @(help|h|\?) ]]; then
    COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
    else
    _filedir
    fi
    fi
    fi
    return 0
    complete -F _svn $default svn
    _svnadmin()
    local cur prev commands options mode
    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    commands='create deltify dump help ? hotcopy list-dblogs \
    list-unused-dblogs load lslocks lstxns recover rmlocks \
    rmtxns setlog verify'
    if [[ $COMP_CWORD -eq 1 ]] ; then
    if [[ "$cur" == -* ]]; then
    COMPREPLY=( $( compgen -W '--version' -- $cur ) )
    else
    COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
    fi
    else
    prev=${COMP_WORDS[COMP_CWORD-1]}
    case $prev in
    --config-dir)
    _filedir -d
    return 0;
    --fs-type)
    COMPREPLY=( $( compgen -W 'fsfs bdb' -- $cur ) )
    return 0;
    esac
    command=${COMP_WORDS[1]}
    if [[ "$cur" == -* ]]; then
    # possible options for the command
    case $command in
    create)
    options='--bdb-txn-nosync \
    --bdb-log-keep --config-dir \
    --fs-type'
    deltify)
    options='-r --revision -q --quiet'
    dump)
    options='-r --revision --incremental \
    -q --quiet --deltas'
    hotcopy)
    options='--clean-logs'
    load)
    options='--ignore-uuid --force-uuid \
    --parent-dir -q --quiet \
    --use-pre-commit-hook \
    --use-post-commit-hook'
    rmtxns)
    options='-q --quiet'
    setlog)
    options='-r --revision --bypass-hooks'
    esac
    options="$options --help -h"
    COMPREPLY=( $( compgen -W "$options" -- $cur ) )
    else
    if [[ "$command" == @(help|h|\?) ]]; then
    COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
    else
    _filedir
    fi
    fi
    fi
    return 0
    complete -F _svnadmin $default svnadmin
    _svnlook()
    local cur prev commands options mode
    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    commands='author cat changed date diff dirs-changed help ? h history \
    info lock log propget pget pg proplist plist pl tree uuid \
    youngest'
    if [[ $COMP_CWORD -eq 1 ]] ; then
    if [[ "$cur" == -* ]]; then
    COMPREPLY=( $( compgen -W '--version' -- $cur ) )
    else
    COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
    fi
    else
    command=${COMP_WORDS[1]}
    if [[ "$cur" == -* ]]; then
    # possible options for the command
    case $command in
    @(author|cat|date|dirs-changed|info|log))
    options='-r --revision -t \
    --transaction'
    changed)
    options='-r --revision -t \
    --transaction --copy-info'
    diff)
    options='-r --revision -t \
    --transaction \
    --no-diff-deleted \
    --no-diff-added \
    --diff-copy-from'
    history)
    options='-r --revision --show-ids'
    prop@(get|list))
    options='-r --revision -t \
    --transaction --revprop'
    tree)
    options='-r --revision -t \
    --transaction --show-ids \
    --full-paths'
    esac
    options="$options --help -h"
    COMPREPLY=( $( compgen -W "$options" -- $cur ) )
    else
    if [[ "$command" == @(help|h|\?) ]]; then
    COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
    else
    _filedir
    fi
    fi
    fi
    return 0
    complete -F _svnlook $default svnlook
    Hope this helps.
    Last edited by alanhaggai (2008-09-21 02:08:12)

  • Bash tab completion broken

    Hi all,
    Probably a dumb question but google has been no help this afternoon but basically my problem is thus:
    In my vnc sessions I cannot tab complete...anything at all.... yet, in putty I can tab just fine.
    Some details...
    bash rc file
    if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
    fi
    # If not running interactively, don't do anything
    [[ $- != *i* ]] && return
    alias ls='ls --color=auto'
    PS1='[\u@\h \W]\$ '
    system
    uname -a
    Linux Kannagi 2.6.38-ARCH #1 SMP PREEMPT Fri Apr 22 20:29:33 CEST 2011 x86_64 Dual-Core AMD Opteron(tm) Processor 2214 HE AuthenticAMD GNU/Linux
    shell
    echo $SHELL
    /bin/bash
    I have everything installed I believe:
    pacman
    pacman -Q |grep -i bash
    bash 4.2.008-1
    bash-completion 1.3-2
    Any ideas? Something I'm missing?
    Thanks!!

    byte wrote:Can you specify somewhere to use a login shell (bash -l)?
    Normally .bashrc gets sourced by .bash_profile, and unless it's a login shell nothing will happen.
    I tried running "bash -l" but the shell I get doesn't have bash completion either : (

  • [Solved] ZSH auto-completion in BASH?

    Hi everyone, I'm using BASH but I really like the way ZSH handles auto completion. For instance, in BASH, if I type vi and press [Tab], it shows my possible options but my cursor makes a new line. Therefore, if I press [Tab] again, the same thing will be created over and over. What I like about ZSH auto-completion is that when I press tab, the auto-completion fills the screen, but my cursor doesn't jump to a new line. Therefore, the actual output of the command and the [Tab] auto-completion output occupy the same space. Does anyone know a way I could have BASH perform in a way similar to this?
    Thanks!
    Last edited by Spara06 (2014-08-30 20:03:52)

    jasonwryan wrote:
    Not as far as I know: this is all down to zle http://zsh.sourceforge.net/Doc/Release/ … dgets.html
    If you want this, just use Zsh (it has all sorts of other advantages as well).
    Thanks for your reply jasonwryan.
    I'm trying out zsh thus far and I'm liking it. It's rather easy to use and has most of the good features of BASH as well as some other nice ones I didn't have before (including the way it does tab completion and right side prompts).
    Thanks!

  • [SOLVED] Trying to make command into bash alias

    Here is a command I would like to make into an easy to use bash alias:
    #Copy results of a find to somewhere
    find -iname "*something*" -exec cp '{}' /path/to/copy/results/to \;
    I realize there are usually several ways to do something in the shell, so if a better way of course I'm all for any tips but if I wanted to make this an alias so that I just had to do:
    alias pattern pathtocopyto
    How would I? I have tried:
    alias findcp="find -iname "$1" -exec cp '{}' $2/ \;"
    But this does not work, says it cannot find the search term when I ran it in a test dir full of properly named files and dirs.
    TIA for any help
    Last edited by colbert (2008-12-17 23:19:09)

    Hmm, I tried that Procyon, I could see the HD light on the case go solid so it was running the find but it did not work. I have a file called "layla.mp3" and a dir called "test" in the current dir, ran it like this:
    findcp layla test
    Gave no result and test was still empty Thanks for the help guys hopefully can get this to go..

  • Help me with a bash alias [SOLVED]

    I want to make a bash alias to `alias tailc=tail -n40 $1 | column -t` so I put that in my ~/.bash_profile but it does not stop after 40 lines. It goes for the whole file. What am I doing wrong?
    Last edited by maggie (2012-12-15 18:36:08)

    +1 - Make a function.  And `column -t` rocks.  I have been looking for a way to tail my server logs with the output being nicely formatted.  Thanks for this post.
    tailc() { tail -n 40 "$1" | column -t; }
    Last edited by graysky (2012-12-15 10:51:27)

  • [SOLVED] ls colors different from tab completion colors

    I've been configuring the colored output of ls and I've got ls colors set, but the colored output from tab completion is different sometimes making it hard to read the files/directories.  Does anyone know where the file that controls the tab completion colors?
    http://i.imgur.com/GwByh.png is a picture showing the issue.
    .dir_colors
    # Configuration file for dircolors, a utility to help you set the
    # LS_COLORS environment variable used by GNU ls with the --color option.
    # Copyright (C) 1996, 1999-2011 Free Software Foundation, Inc.
    # Copying and distribution of this file, with or without modification,
    # are permitted provided the copyright notice and this notice are preserved.
    # The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
    # slackware version of dircolors) are recognized but ignored.
    # Below, there should be one TERM entry for each termtype that is colorizable
    TERM Eterm
    TERM ansi
    TERM color-xterm
    TERM con132x25
    TERM con132x30
    TERM con132x43
    TERM con132x60
    TERM con80x25
    TERM con80x28
    TERM con80x30
    TERM con80x43
    TERM con80x50
    TERM con80x60
    TERM cons25
    TERM console
    TERM cygwin
    TERM dtterm
    TERM eterm-color
    TERM gnome
    TERM gnome-256color
    TERM jfbterm
    TERM konsole
    TERM kterm
    TERM linux
    TERM linux-c
    TERM mach-color
    TERM mlterm
    TERM putty
    TERM rxvt
    TERM rxvt-256color
    TERM rxvt-cygwin
    TERM rxvt-cygwin-native
    TERM rxvt-unicode
    TERM rxvt-unicode-256color
    TERM rxvt-unicode256
    TERM screen
    TERM screen-256color
    TERM screen-256color-bce
    TERM screen-bce
    TERM screen-w
    TERM screen.rxvt
    TERM screen.linux
    TERM terminator
    TERM vt100
    TERM xterm
    TERM xterm-16color
    TERM xterm-256color
    TERM xterm-88color
    TERM xterm-color
    TERM xterm-debian
    # Below are the color init strings for the basic file types. A color init
    # string consists of one or more of the following numeric codes:
    # Attribute codes:
    # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
    # Text color codes:
    # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
    # Background color codes:
    # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
    #NORMAL 00 # no color code at all
    #FILE 00 # regular file: use no color at all
    #RESET 0 # reset to "normal" color
    DIR 01;34 # directory
    LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
    # numerical value, the color is as for the file pointed to.)
    MULTIHARDLINK 00 # regular file with more than one link
    FIFO 40;33 # pipe
    SOCK 01;35 # socket
    DOOR 01;35 # door
    BLK 40;33;01 # block device driver
    CHR 40;33;01 # character device driver
    ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file
    SETUID 37;41 # file that is setuid (u+s)
    SETGID 30;40 # file that is setgid (g+s)
    CAPABILITY 30;41 # file with capability
    STICKY_OTHER_WRITABLE 32;40 # dir that is sticky and other-writable (+t,o+w)
    OTHER_WRITABLE 35;40 # dir that is other-writable (o+w) and not sticky
    STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
    # This is for files with execute permission:
    EXEC 01;32
    # List any file extensions like '.gz' or '.tar' that you would like ls
    # to colorize below. Put the extension, a space, and the color init string.
    # (and any comments you want to add after a '#')
    # If you use DOS-style suffixes, you may want to uncomment the following:
    #.cmd 01;32 # executables (bright green)
    #.exe 01;32
    #.com 01;32
    #.btm 01;32
    #.bat 01;32
    # Or if you want to colorize scripts even if they do not have the
    # executable bit actually set.
    #.sh 01;32
    #.csh 01;32
    # archives or compressed (bright red)
    .tar 01;31
    .tgz 01;31
    .arj 01;31
    .taz 01;31
    .lzh 01;31
    .lzma 01;31
    .tlz 01;31
    .txz 01;31
    .zip 01;31
    .z 01;31
    .Z 01;31
    .dz 01;31
    .gz 01;31
    .lz 01;31
    .xz 01;31
    .bz2 01;31
    .bz 01;31
    .tbz 01;31
    .tbz2 01;31
    .tz 01;31
    .deb 01;31
    .rpm 01;31
    .jar 01;31
    .war 01;31
    .ear 01;31
    .sar 01;31
    .rar 01;31
    .ace 01;31
    .zoo 01;31
    .cpio 01;31
    .7z 01;31
    .rz 01;31
    # image formats
    .jpg 01;35
    .jpeg 01;35
    .gif 01;35
    .bmp 01;35
    .pbm 01;35
    .pgm 01;35
    .ppm 01;35
    .tga 01;35
    .xbm 01;35
    .xpm 01;35
    .tif 01;35
    .tiff 01;35
    .png 01;35
    .svg 01;35
    .svgz 01;35
    .mng 01;35
    .pcx 01;35
    .mov 01;35
    .mpg 01;35
    .mpeg 01;35
    .m2v 01;35
    .mkv 01;35
    .ogm 01;35
    .mp4 01;35
    .m4v 01;35
    .mp4v 01;35
    .vob 01;35
    .qt 01;35
    .nuv 01;35
    .wmv 01;35
    .asf 01;35
    .rm 01;35
    .rmvb 01;35
    .flc 01;35
    .avi 01;35
    .fli 01;35
    .flv 01;35
    .gl 01;35
    .dl 01;35
    .xcf 01;35
    .xwd 01;35
    .yuv 01;35
    .cgm 01;35
    .emf 01;35
    # http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
    .axv 01;35
    .anx 01;35
    .ogv 01;35
    .ogx 01;35
    # audio formats
    .aac 00;36
    .au 00;36
    .flac 00;36
    .mid 00;36
    .midi 00;36
    .mka 00;36
    .mp3 00;36
    .mpc 00;36
    .ogg 00;36
    .ra 00;36
    .wav 00;36
    # http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
    .axa 00;36
    .oga 00;36
    .spx 00;36
    .xspf 00;36
    I'm using zsh.
    Last edited by livinglifeback (2011-08-13 18:52:03)

    I myself just uses the standard colors and don't change them from default, but I do get the same colors for both ls and completion with this in .zshrc:
    eval `dircolors -b`
    zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}

  • Tab completion with a Unix Shell simulation

    Hi everyone,
    I am writing a command line program which needs to interface a Unix Shell.
    when I type "!command", it will send the command to a bash process and read the output then write it on stdout.
    The bash I am running merges stdout and stderr (exec 2>&1).
    Everything works great, but now I would like to add the tab-completion functionality.
    I would just need to send (tab) to the process so that I can read the output completion, I tried many ways but without success.
    Also, I saw we can specify the tag for completion in file ~/.inputrc, but if my tag does not end with \n, I will write it in the buffer and we will be red by bash only after \n is typed.
    I hope I made myself clear.
    Thanks for your help!
    Dimebag

    That is the point.
    I did try with out.write((char)9) twice followed by
    flush(), however the data gets stuck in the buffer
    and will only be received after the next command
    (finishing with \n).
    I would need to use println but this does not work
    either.Ahh, I see...
    According to this page (http://www.die.net/doc/linux/man/man1/screen.1.html), vt100 allows you to send 'ESC [ Pn I", or {(char)33, (char)91, (char)0, (char)73} as an escape code for the horizontal tab. I don't know if that will work either (never done terminal emulation), but it might be worth a shot.
    As an aside, an alias for Bash's tab completion is a Control I, but I don't know what that translates to, if not the weird escape sequence above.

  • Useful tab-completion for .bashrc

    I was searching for a tab completion in systemd commands such as:
    $ systemct <TAB> (this show all possible parameters/flags) and another <TAB> (show all units and itself commands).
    Reading posts here and there I found that the following command in .bashrc:
    complete -F or -C command
    did the trick, but this is awful and painfull  cause I need to implement it in all commands, such as, pacman, man, sudo, etc. Ok, googling, I found this usefull script you can put in your .bashrc:
    # completion.bash
    _vault_complete() {
    COMPREPLY=()
    local word="${COMP_WORDS[COMP_CWORD]}"
    local completions="$(vault --cmplt "$word")"
    COMPREPLY=( $(compgen -W "$completions" -- "$word") )
    complete -f -F _vault_complete vault
    This will complete all your commands with infinite posibilities. (This example use command vault, you can use whatever you want)
    I put the link (well explained) here because there is a way to do it in zshell for those interested on it.
    http://goo.gl/RFwgK
    I hope this can be help someone.
    Cheers
    Maybe would be useful to put this script on the bashrc wiki.
    Last edited by JohnnyDeacon (2013-05-21 13:21:21)

    firecat53 wrote:
    Just wondering if you actually tested this first...from what I read on the link you provided, this script fragment provided completion for the 'vault' command only if I'm understanding it correctly. In order to make this work for any command, you would have to repeat that shell fragment for _each_ command. Not sure what this gets you over just using 'complete -cf <cmd>'.
    I think the author was just explaining how to create a bash completion script for an arbitrary command that could be included along with that command. Most software packages have those bash completion scripts already included. This could be used for a command that doesn't include that script already. If that's what you intended with your post it wasn't clear to me :-)
    Scott
    Edit:  I also just noticed that without even having 'complete -cf systemctl' in my .bashrc, bash is still giving me a list of possible systemctl options when I hit <TAB> after typing systemctl. Ooo, nice! Never noticed that before
    complete -cf <cmd> does not complete with flags and parameters.
    I have noticed about a script called bash-completion on repos that do completion very well, I'll check it out if it works with all commands.

  • Tab-completion after directories containing spaces broken

    Hello,
    Some days ago I noticed that tab-completion doesn't work any more on files and directories that contain spaces. I'm pretty sure that it has. I'm using bash (3.1.17-1). I don't know when this happened, but my suspicion is that it is related to the upgrade to readline 5.2. Has anyone else experienced this? (Maybe someone can be a bit more specific than I )
    Hm, here are some other perhaps interesting settings on my system:
    LOCALE="en_US.ISO-8859-1"
    KEYMAP="sv-latin1.map.gz"
    CONSOLEFONT="lat1-16.psfu.gz"
    CONSOLEMAP="8859-1"
    Regards

    Romashka wrote:Probably due to upgrade of readline while bash was not recompiled.
    In bug report somebody mentioned that he recompiled bash against current readline without success in resolving the issue (so did slubman a moment ago). I think that's rather bash itself  or bash/readline (not likely since new bash works properly) problem.
    Anyway I'm stopping before I'll turn this thread into bug system I'm going to watch bug reports since now without "bugging" you (a insectorium in one phrase )
    Thanks a lot for your replies and interest!

  • Using Tab Completion

    I am just starting to work with command-line navigation in terminal. They say "tab completion" is a absolute time-saving feature.
    It worked for me the first time, but now it doesn't. At my home folder, I enter cd, then p and press the Tab key. After pressing the tab key a second time, it should display all choices beginning with p. Nothing happens. Any ideas?

    baltwo wrote:
    Hmmm! I have a simple bash shell set up and all I get is the alert sound. Maybe you're using another shell or have something else set that accounts for the discrepancy.
    Nope. I'm using the system default bash. If I try to complete something that isn't there, such as "cd p", I get an alert. If I try something that has possible completions, like "cd P", I get a list of the directories.

  • "Tab Completion" closing console sessions

    Starting this morning I find that pressing the TAB key terminates console sessions. For instance, running KDE as a user if I run "konsole", then su to root - pressing tab will return me to user console and pressing tab again will close konsole app (Session shell exited with signal 11).
    A text console (ctl-alt-f1) will also terminate pressing tab so not an X problem.
    I did a pacman -Suy yesterday and sed, dbus and vte packages were updated but I can't see anything in those. Dodgy keyboard? I don't know much about termcaps so am a bit stuck.
    A nuisance as I use tab completion quite often.
    EDIT: Hmm, rebooted and problem has gone!

    byte wrote:Can you specify somewhere to use a login shell (bash -l)?
    Normally .bashrc gets sourced by .bash_profile, and unless it's a login shell nothing will happen.
    I tried running "bash -l" but the shell I get doesn't have bash completion either : (

  • Root user tab completion in vi editing mode

    When I su to the root user at the terminal I lose tab completion. Whenever I press TAB to complete a file or directory name I get an actual tab character.
    I've tried editing ~/.inputrc for root and this seems to work for emacs editing mode but if I switch to vi mode using 'set -o vi' I lose completions and get tabs.
    I don't have this problem with a normal user, just when I switch to root. Does anyone know what I'm doing wrong?

    I managed to solve it!  Add the following to ~root/.inputrc (or /etc/inputrc):
    "\t": complete
    This maps the TAB key to the 'complete' function.  Don't know why it isn't already for root when it is for other users.

Maybe you are looking for

  • Single Sign On and Application with Web Services

    My Application Server is set as partner application for SSO so for example this address: http://myserver:80 is SSO enabled. I have two ADF applications on it with jspx pages and the ADF security is enabled on them. SSO works for these applications (f

  • Adobe Camera Raw plugin for Photoshop 7

    Is it still possible to purchase the Adobe Camera Raw plugin for Photoshop 7? If so, can the plugin read *.raw files from an Olympus C-8080?

  • Can't edit Vcards in Address Book

    In Address Book, the "edit card" in Edit drop-down menu is grayed out (as is the "delete").  In addition, on the bottom of an individual Address Book page, the "EDIT" option no longer appears.  Each Adress Book page shows only the Add and Share optio

  • How can I share my external drive?

    Hi I have an imac G5 and an imac intel core duo, each one has an external drive, and they are connected through the network, but I can´t reach my intel core duo´s external drive from my imac G5. The imac G5 has the tiger OS, the other one has the sno

  • Received unexpected message type does not match expected type

    1.Two Biztalk Applications A,B  one for sending the request(A) and other application will send the response to A. 2.I have two schema  Request and Response in Aplication A which i have exposed as webservice. 3. Application B share the same response s