Skip to content

Instantly share code, notes, and snippets.

@mogeko
Last active June 13, 2020 22:05
Show Gist options
  • Select an option

  • Save mogeko/a0e1fa7d0b59f63d00fcb6c125ee9350 to your computer and use it in GitHub Desktop.

Select an option

Save mogeko/a0e1fa7d0b59f63d00fcb6c125ee9350 to your computer and use it in GitHub Desktop.

Revisions

  1. mogeko revised this gist Jun 13, 2020. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,13 @@ HISTFILESIZE=2000
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize

    # If set, allow to enter directory without using cd command.
    shopt -s autocd

    # Check the spelling of the directory name in the cd command.
    # Only for interactive shell
    shopt -s cdspell

    # If set, the pattern "**" used in a pathname expansion context will
    # match all files and zero or more directories and subdirectories.
    #shopt -s globstar
    @@ -64,5 +71,5 @@ if ! shopt -oq posix; then
    fi
    fi

    #export PS1='[\[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\] \W]\\$ '
    export PS1='\[\e[38;5;046m\][\[\e[38;5;226m\]\t \[\e[38;5;197m\]\w\[\e[38;5;046m\]]\$\[\e[m\] '
    #PS1='[\[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\] \W]\\$ '
    PS1='\[\e[38;5;046m\][\[\e[38;5;226m\]\t \[\e[38;5;197m\]\w\[\e[38;5;046m\]]\$\[\e[m\] '
  2. mogeko revised this gist Jun 3, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -64,5 +64,5 @@ if ! shopt -oq posix; then
    fi
    fi

    export PS1='[\[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\] \W]\\$ '

    #export PS1='[\[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\] \W]\\$ '
    export PS1='\[\e[38;5;046m\][\[\e[38;5;226m\]\t \[\e[38;5;197m\]\w\[\e[38;5;046m\]]\$\[\e[m\] '
  3. mogeko revised this gist Jun 3, 2020. 1 changed file with 0 additions and 64 deletions.
    64 changes: 0 additions & 64 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -1,64 +0,0 @@
    # User alias.bash_aliases
    alias cls='clear'
    alias now='date +"%T"'
    alias nowdate='date +"%d-%m-%Y"'
    alias nowtime='now'
    alias path='echo -e ${PATH//:/\\n}'
    alias ping='ping -c 5'
    alias rm='rm -I --preserve-root'
    alias mv='mv -i'
    alias cp='cp -i'
    alias ln='ln -i'
    alias chown='chown --preserve-root'
    alias chmod='chmod --preserve-root'
    alias chgrp='chgrp --preserve-root'
    alias getpass='openssl rand -base64 20'
    alias removerc='dpkg --list | grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge'
    alias myip='/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6'
    alias gc='git commit'
    alias gco='git checkout'
    alias bdm="!git branch --merged | grep -v '*' | xargs -n 1 git branch -d"
    alias top='htop'
    alias targz='tar -czvf'
    alias wgetall='wget -r -np -nd'
    #alias git='hub'

    extract() {
    if [ -z "$1" ]; then
    # display usage if no parameters given
    echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
    else
    if [ -f $1 ] ; then
    #NAME=${1%.*}
    #mkdir $NAME && cd $NAME
    case $1 in
    *.tar.bz2) tar -xvjf $1 ;;
    *.tar.gz) tar -xvzf $1 ;;
    *.tar.xz) tar -xvJf $1 ;;
    *.lzma) unlzma $1 ;;
    *.bz2) bunzip2 $1 ;;
    *.rar) unrar x -ad $1 ;;
    *.gz) gunzip $1 ;;
    *.tar) tar -xvf $1 ;;
    *.tbz2) tar -xvjf $1 ;;
    *.tgz) tar -xvzf $1 ;;
    *.zip) unzip $1 ;;
    *.Z) uncompress $1 ;;
    *.7z) 7z x $1 ;;
    *.xz) unxz $1 ;;
    *.exe) cabextract $1 ;;
    *) echo "extract: '$1' - unknown archive method" ;;
    esac
    else
    echo "$1 - file does not exist"
    fi
    fi
    }
    backup() { cp "$1"{,.bak};}
    stopwatch() {
    START=`date +%s%N`;
    $1
    END=`date +%s%N`;
    time=$((END-START))
    echo "scale=4; $time / 1000000000" | bc
    }
  4. mogeko created this gist Jun 3, 2020.
    64 changes: 64 additions & 0 deletions .bash_aliases
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    # User alias.bash_aliases
    alias cls='clear'
    alias now='date +"%T"'
    alias nowdate='date +"%d-%m-%Y"'
    alias nowtime='now'
    alias path='echo -e ${PATH//:/\\n}'
    alias ping='ping -c 5'
    alias rm='rm -I --preserve-root'
    alias mv='mv -i'
    alias cp='cp -i'
    alias ln='ln -i'
    alias chown='chown --preserve-root'
    alias chmod='chmod --preserve-root'
    alias chgrp='chgrp --preserve-root'
    alias getpass='openssl rand -base64 20'
    alias removerc='dpkg --list | grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge'
    alias myip='/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6'
    alias gc='git commit'
    alias gco='git checkout'
    alias bdm="!git branch --merged | grep -v '*' | xargs -n 1 git branch -d"
    alias top='htop'
    alias targz='tar -czvf'
    alias wgetall='wget -r -np -nd'
    #alias git='hub'

    extract() {
    if [ -z "$1" ]; then
    # display usage if no parameters given
    echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
    else
    if [ -f $1 ] ; then
    #NAME=${1%.*}
    #mkdir $NAME && cd $NAME
    case $1 in
    *.tar.bz2) tar -xvjf $1 ;;
    *.tar.gz) tar -xvzf $1 ;;
    *.tar.xz) tar -xvJf $1 ;;
    *.lzma) unlzma $1 ;;
    *.bz2) bunzip2 $1 ;;
    *.rar) unrar x -ad $1 ;;
    *.gz) gunzip $1 ;;
    *.tar) tar -xvf $1 ;;
    *.tbz2) tar -xvjf $1 ;;
    *.tgz) tar -xvzf $1 ;;
    *.zip) unzip $1 ;;
    *.Z) uncompress $1 ;;
    *.7z) 7z x $1 ;;
    *.xz) unxz $1 ;;
    *.exe) cabextract $1 ;;
    *) echo "extract: '$1' - unknown archive method" ;;
    esac
    else
    echo "$1 - file does not exist"
    fi
    fi
    }
    backup() { cp "$1"{,.bak};}
    stopwatch() {
    START=`date +%s%N`;
    $1
    END=`date +%s%N`;
    time=$((END-START))
    echo "scale=4; $time / 1000000000" | bc
    }
    68 changes: 68 additions & 0 deletions .bashrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    #
    # ~/.bashrc
    #

    # If not running interactively, don't do anything
    [[ $- != *i* ]] && return

    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000

    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize

    # If set, the pattern "**" used in a pathname expansion context will
    # match all files and zero or more directories and subdirectories.
    #shopt -s globstar

    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    fi

    # colored GCC warnings and errors
    export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'

    # Add an "alert" alias for long running commands. Use like so:
    # sleep 10; alert
    alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.

    if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
    fi

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if ! shopt -oq posix; then
    if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
    elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
    fi
    fi

    export PS1='[\[\e[32m\]\u\[\e[m\]\[\e[32m\]@\[\e[m\]\[\e[32m\]\h\[\e[m\] \W]\\$ '