DEV Community

Discussion on: What are your favorite bash aliases?

Collapse
 
aetherunbound profile image
Madison Swain-Bowden

Good topic Roelof!

I've got some similar ones, with one minor difference:

alias ebrc='vim ~/.bashrc && source ~/.bashrc'

This makes it so that my .bashrc is sourced right after I finish editing it!

I've also got a few convenience functions for common operations:

cdl_function () {
    cd $1 && ls -lah
}

mkdirc_function () {
    mkdir $1 && cd $1
}

alias cdl=cdl_function
alias mkdirc=mkdirc_function

And some conda specific ones:

# Tab completed virtual environments
# e.g. `vact <tab>`
vact () {
    conda activate ${1}
}
__vact()
{
    local cur=${COMP_WORDS[COMP_CWORD]}
    IFS=$'\n'
    tmp=( $(compgen -W "$(ls ${CONDA_PREFIX}/envs/ )" -- $cur))
    # COMPREPLY=( "${tmp[@]// /\ }" )
    COMPREPLY=( "${tmp[@]}" )
}
complete -F __vact vact

# List environments
alias le="conda info --envs"
Collapse
 
roelofjanelsinga profile image
Roelof Jan Elsinga

Oh I'm definitely adding those first three! They cover about 99% of my manual actions automatically, great aliases!

The tab completion I'm not familiar with, but that does look like some amazing productivity hacks!