Bash completions for Julia

I bundled up my local Bash completions for Julia in a repository since I think it might be useful for others: fredrikekre/julia-completions. The completions are fairly “smart” and, for example, only complete *.toml files after the --project flag, and only yes/no after --startup-file etc.

Installation is very easy (see the README):

  1. Download the script:
    mkdir -p ~/.bash_completion.d
    curl -fsSL -o ~/.bash_completion.d/julia-completion.bash \
         https://raw.githubusercontent.com/fredrikekre/julia-completions/master/julia-completion.bash
    
  2. Hook into the shell:
    echo '# Bash completion for julia, see https://github.com/fredrikekre/julia-completions
    if [[ -f ~/.bash_completion.d/julia-completion.bash ]]; then
        . ~/.bash_completion.d/julia-completion.bash
    fi' >> ~/.bashrc
    

This will add completions for the julia command. If you want to add completions also for other commands/aliases, e.g. julia-master, you can simply add

complete -F _julia julia-master

to ~/.bashrc after sourcing the script above.

I hope some of you find it useful!

13 Likes