loading...

re: My Shell Aliases VIEW POST

FULL DISCUSSION
 

I don't believe in one character aliases. I utilize tabs to reduce keystrokes. My aliases are some per-configuration for tools. And some personalized tools are prefixed with fl_ or with flp_


#-------------------------------------------------------------
# Aliases for windows like functionality
#-------------------------------------------------------------

alias cmd="gnome-terminal"
alias cd..="cd .."
alias md="mkdir -p"
alias cls="clear"
alias ipconfig="ifconfig"
#-------------------------------------------------------------
# Aliases for sane functionality
#-------------------------------------------------------------

alias rm="rm -rf --preserve-root"
alias lla="ls -la --color=auto"
alias lsd="ls -d */ --color=auto"
alias lld="ls -ld */ --color=auto"
alias llf="ls -al --color=auto | grep '^[-l]'"
alias lsf="ls -a --color=auto | grep '^[-l]'"
alias cd-="cd -"
alias cd~="cd ~"
alias cdd="cd -P"


#-------------------------------------------------------------
# App Specific Aliases 
#-------------------------------------------------------------

#  Youtube-dl - dnf install youtube-dl ffmpeg ffmpeg-libs

alias youtube-dl-mp3="youtube-dl -x --audio-format mp3 "
alias youtube-dl-playlist="youtube-dl -cio '%(autonumber)s-%(title)s.%(ext)s' "

# Hub - https://hub.github.com/
alias git="hub"

#-------------------------------------------------------------
# Simple docker 
#-------------------------------------------------------------


# Remove all the <none> images. Even though it is not recommended.
alias fl_docker_remove_dangling='docker rmi $(docker images -f dangling=true -q)'

# Stop all running docker containers.
alias fl_docker_stop_all='docker stop $(docker ps -aq)'

# Kill all running containers.
alias fl_docker_kill_containers='docker kill $(docker ps -q)'

# Delete all stopped containers: 'docker rm $(docker ps -a -q)'
alias fl_docker_clean_containers='docker container prune'

# Delete all saved images:  'docker rmi $(docker images -q)'
alias fl_docker_clean_images='docker image prune'

# Delete all containers and images
alias fl_docker_clean_all='docker system prune'

# Restart all containers
alias fl_docker_restart_all='docker restart $(docker ps -a -q)'

# Start all stopped containers:
alias fl_docker_restart_stopped='docker start $(docker ps -a -q -f status=exited)'



#-------------------------------------------------------------
# Better progressbar in axel 
#-------------------------------------------------------------

alias axel="axel -d"

#-------------------------------------------------------------
# Mimic the behavior of Mac Open Command while preserving the 
# errors generated.
#   N.B.  Replaced by much more roubust open function.
#-------------------------------------------------------------

#alias open="xdg-open &>$HOME/.xsession-errors"

#-------------------------------------------------------------
# Search History.
#   Usage: histg <keyword>
#-------------------------------------------------------------

alias histg="history | grep"

#-------------------------------------------------------------
# Show which applications are connecting to the network.
#-------------------------------------------------------------

alias listen="lsof -P -i -n" 

#-------------------------------------------------------------
# Show the active ports
#-------------------------------------------------------------

alias show-port='netstat -tulanp'

#-------------------------------------------------------------
# Ubuntu like update-grub command.
#-------------------------------------------------------------

alias update-grub='sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg'
 

I also have some utility functions like



backup() { cp "$1"{,.bak};} 
mcd() {   [ -n "$1" ] && mkdir -p "$@" && cd "$1";   }
psx() { ps -ax | grep -v grep | grep "$@"; }function psx() { ps -ax | grep -v grep | grep "$@"; }

pskill(){
    ps aux | grep "$1" | grep -v grep | awk '{print $2;}' | while read p; do kill -9 $p; done
}


extract() { 
    if [ -f $1 ] ; then 
      case $1 in 
        *.tar.bz2)   tar xjf $1     ;; 
        *.tar.gz)    tar xzf $1     ;; 
        *.bz2)       bunzip2 $1     ;; 
        *.rar)       unrar e $1     ;; 
        *.gz)        gunzip $1      ;; 
        *.tar)       tar xf $1      ;; 
        *.tbz2)      tar xjf $1     ;; 
        *.tgz)       tar xzf $1     ;; 
        *.zip)       unzip $1       ;; 
        *.Z)         uncompress $1  ;; 
        *.7z)        7z x $1        ;; 
        *)     echo "'$1' cannot be extracted via extract()" ;; 
         esac 
     else 
         echo "'$1' is not a valid file" 
     fi 
}

#-------------------------------------------------------------
# Mimic the behavior of Mac Open Command while preserving the 
# errors generated
#-------------------------------------------------------------

open() {
    if [ $# -eq 0 ]
    then    
        xdg-open .;
    else
        xdg-open "$@" &>/home/Abhinav/.xsession-errors;
    fi
}

Code of Conduct Report abuse