summaryrefslogtreecommitdiff
path: root/bash/bashrc
blob: 3c71d56e2c4719a8821c194f165c27428add6201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# history setup

## append to the history file, don't overwrite it
shopt -s histappend

## no dups+skip space-prefixed commands
HISTCONTROL=ignoreboth
HISTFILE=~/.local/var/bash/history
HISTSIZE=65536

# activate lesspipe
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# TODO: split off aliases?
# ls colors
if [ -x /usr/bin/dircolors ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
fi

alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -l'
alias la='ls -A'
alias lh='ls -lh'
alias lla='ls -lA'
alias llh='ls -lAh'
alias lt='ls -lt'

# disable flow control
# XXX should this be here?
stty -ixon

cu()
{
    local lvl=$1
    if ! [[ "${lvl}" =~ ^[0-9]+$ ]]; then
        echo "Parameter must be a non-negative integer: ${lvl}"
        return 1
    fi

    local dir=""
    for i in $(seq "${lvl}"); do
        dir=${dir}../
    done

    cd "${dir}"
}

# ups.khirnov.net uploader
ups() {
    if [ "$1" ]; then
        fname=$(basename "$1")
    else
        fname="-"
    fi

    url=$(curl -sS -E ~/.local/var/up/cert --data-binary "@${fname}" "https://ups.khirnov.net/${fname}")
    [ "${url}" ] && echo "${url}"
}

# up.khirnov.net 0x0 instance
up() {
    if [ "$1" ]; then
        fname=$(basename "$1")
    else
        fname="-"
    fi

    url=$(curl -sS -E ~/.local/var/up/cert -F "file=@${fname}" "https://up.khirnov.net/")
    [ "${url}" ] && echo "${url}"
}

# define the prompt
. ~/.config/bash/prompt
PS1=$(__prompt_func)

# source the machine-local configuration
[ -r "$HOME/.config/bash/bashrc_local.bash" ] && . "$HOME/.config/bash/bashrc_local.bash"