Skip to content


.bashrc

# Jacson's .bashrc extra functions/lines

PS1='${debian_chroot:+($debian_chroot)}\[\033[02;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\$ '

# Alias
alias copia='rsync -avh --progress'
alias convmv_wintolinux='convmv -f cp850 -t utf8'

alias tempopdt='TZ=America/Los_Angeles date'
alias date_pdt='tempopdt'
alias datepdt='tempopdt'
alias tempoPDT='tempopdt'
alias tempo_pdt='tempopdt'

alias grep='grep --color'

alias gwenview='`which gwenview` &> /dev/null'
alias okular='`which okular` &> /dev/null'
alias kwrite='`which kwrite` &> /dev/null'
alias kate='`which kate` &> /dev/null'

alias ifconfig='/sbin/ifconfig'
alias iwconfig='/sbin/iwconfig'
alias iwlist='/sbin/iwlist'
alias route='/sbin/route'

alias l='ls -CF'
alias la='ls -A'
alias ll='ls -l'
alias ls='ls --color=auto'

alias mv='mv -iv'
alias rm='rm -iv'
alias s='ls'
alias sl='ls'

alias grep=grep\ --color

alias youtube-dl-best="youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio' --merge-output-format mp4"

alias recordffmpeg='echo ffmpeg -f x11grab -r 25 -s 840x480 -i :0.0+420,265 -vcodec libx264 -preset ultrafast ANGRY_BIRDS_GAMEPLAY.mkv;echo http://trac.ffmpeg.org/wiki/Capture/Desktop'

alias juntar_pdf='echo -e "Use: \033[31mpdfunite\033[0m (poppler-utils): \033[36mpdfunite pdf1 pdf2 pdfDestino\033[0m\n ou: \033[31mpdfjam\033[0m (textlive-extra-utils): \033[36mpdfjam pdf1 pdf2 -o pdfDestino\033[0m"'
alias pdf_join='juntar_pdf'
alias createslideshow='$HOME/Develop/createSlideShow/create_slideshow.py'

alias mplayer_no_sc='mplayer -zoom 1 -xineramascreen 1 -heartbeat-cmd "xscreensaver-command -deactivate" -fs'

# Exports
export EDITOR=vim

# Functions
convert_to_webm () 
{ 
    ffmpeg -i $1 -ss 00:00:26.800 -t 6.5 -c:v libvpx -vf scale="1280:-1" -an ${1%.*}.webm
}

dequote () 
{ 
    eval printf %s "$1" 2> /dev/null
}

mv_low2up () 
{ 
    MAX=$#;
    for ((i=1; i<=$MAX; i++))
    do
        eval NOME=\${$i};
        [ "$NOME" != "${NOME^^}" ] && mv -iv -iv "$NOME" "${NOME^^}";
    done
}

mv_spaces () 
{ 
    MAX=$#;
    for ((i=1; i<=$MAX; i++))
    do
        eval NOME=\${$i};
        [ "$NOME" != "${NOME// /_}" ] && mv -iv -iv "$NOME" "${NOME// /_}";
    done
}

mv_up2low () 
{ 
    MAX=$#;
    for ((i=1; i<=$MAX; i++))
    do
        eval NOME=\${$i};
        [ "$NOME" != "${NOME,,}" ] && mv -iv -iv "$NOME" "${NOME,,}";
    done
}

quote () 
{ 
    local quoted=${1//\'/\'\\\'\'};
    printf "'%s'" "$quoted"
}

quote_readline () 
{ 
    local quoted;
    _quote_readline_by_ref "$1" ret;
    printf %s "$ret"
}

rawurldecode () 
{ 
    printf '%b' "${1//%/\\x}"
}

ver_webcam () 
{ 
    RES_1=width=640:height=480;
    RES_2=width=322:height=288;
    echo 'Informe a resolução desejada:';
    echo '  [1] 640x480';
    echo '  [2] 322x288';
    read resp;
    case "$resp" in 
        1*)
            RES=$RES_1
        ;;
        *)
            RES=$RES_2
        ;;
    esac;
    mplayer tv:// -vf mirror,eq=7:6 -tv driver=v4l2:$RES:device=/dev/video0
}

webcam_fake ()
{
    if [ $# -ne 2 ];then
        echo "Use: webcam_fake /dev/video? arquivo_video"
        return
    fi
    VIDEO_DEV=$1
    VIDEO_FILE=$2
    mkfifo /tmp/.pipe
    yuv4mpeg_to_v4l2 $VIDEO_DEV < /tmp/.pipe &
    mplayer $VIDEO_FILE -vf scale=480:360 -vo yuv4mpeg:file=/tmp/.pipe
}

download4c ()
{
    if [ $# -ne 1 ];then
        echo "Use: download4c http://postURL"
        return
    fi
    wget "$1" -O tmp || return
    tr '<' '\n' < tmp | grep 'a href.*4cdn' | cut -d\" -f2 | xargs -L1 -i{} wget -c http:{}
    rm -f tmp
}

remove_invalid_names ()
{
    find $1 -type f -print0 | perl -n0e '$new = $_; if($new =~ s/[^[:ascii:]]/_/g) {
      print("Renaming $_ to $new\n"); rename($_, $new);
    }'
}

create_slideshow()
{
    [ -z "$1" -o -z "$2" ] && { echo "Use: create_slideshow FRAMES ARQ_SAIDA.mp4";return 0; }
    ffmpeg -framerate $1 -pattern_type glob -i '*.png' -c:v libx264 -pix_fmt yuv420p "$2"
}

getsrttext() {
    if [ $# -ne 1 ];then
        echo "Use: getsrttext FILE"
        return
    fi
    awk '{if (!(NF == 1 && $1 == $1+0 || $2 == "-->" && substr($1,":") && substr($3,":") || NF == 1 && ($NF == "" || $NF == "\r" || $NF == "\t"))) print }' "$1" | \
        tr '\n' ' ' | sed 's;\r;;g ; s;\. ;.\n;g'
}

gif_how_to() {
    echo '
To extract the images:
  convert arquivo.gif -coalesce foo-%03d.png
To create the new gif:
  convert -delay 5 -loop 0 *.png  novo.gif
'
}

free_swap() {
    sudo bash -c 'swapoff -a;swapon -a'
}

format_text() {
    XCLIP=`which xclip || which cat`
    case $XCLIP in *xclip*) XCLIP="$XCLIP -selection c";FLAG=1;;*)FLAG=0;;esac

    echo -e "\n\033[1mTexto:\033[0m"
    tr \\n \  <<< "$@" | sed 's;\.\( \)\+;\.\n;g' | $XCLIP
    [ $FLAG -eq 1 ] && {
        $XCLIP -o
        echo -e "\n\033[1mTexto copiado para a área de transferência\033[0m"
    }
}

Postado em 🐧 GNU/Linux 🐧.