#!/bin/sh

umask 007

export PATH='/bin'
export PS1='\u@\h \w \$ '
export EDITOR='vi'
export LESS='-Ri'
export LESSHISTFILE='-'
export PAGER='less'
export SHELL='/bin/bash'
export COLORTERM=truecolor
export TERM=xterm-256color
export TERMINAL=xfce4-terminal
export MC_SKIN=julia256
export HISTCONTROL=ignoreboth
export NO_AT_BRIDGE=1
export HISTSIZE=5123
export HISTIGNORE='poweroff:reboot'

alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias cd..='cd ..'

alias v='vi'
alias ls='ls -v --color=auto'
alias ll='ls -alhF'
alias l='ll'
alias le='less'
alias els='less'
alias les='less'
alias lel='less'
alias grep='grep -i --color=auto'
alias rgrep='grep -r'
alias cp='cp -i'
alias mv='mv -i'
alias hd='hexdump -C'
alias ffmpeg='ffmpeg -hide_banner'
alias ffprobe='ffprobe -hide_banner'
alias lszip='unzip -l'

alias gco='git commit'
alias ga='git add'
alias gc='git checkout'
alias gb='git branch'
alias gs='git status'
alias gss='git show'
alias gsw='git show --word-diff'
alias gsd='git show --word-diff-regex=.'
alias gp='git pull'
alias gd='git diff'
alias gdw='git diff --word-diff'
alias gdd='git diff --word-diff-regex=.'
alias gn='git diff --staged'
alias gl='git log --oneline --decorate --graph'
alias gr='git restore --staged'
alias gap='git add -p'
alias grp='git restore --staged -p'

zipfile() {
    target="$1"
    shift
    tar -zcvf "$target" "$@"
}

serve_file() {
    echo "Serving '$1' on localhost:8080"
    length=$(stat --format=%s "$1")
    while true; do { echo -ne "HTTP/1.1 200 OK\r\nContent-Length: $length\r\n\r\n" ; cat "$1" ; } | nc -lnp 8080 ; done
}

ec() {
    echo -e "\e[1;31mExit code: $?\e[m\n"
}
