aboutsummaryrefslogtreecommitdiff
path: root/config/zsh/30-behavior.zsh
blob: f2e483e7c3349a7f7fd2ebae9a04f9d3c145f071 (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
#
# execution

setopt rm_star_wait   # wait 10 seconds before accepting 'rm *' confirmation
export REPORTTIME=5   # report timing for any command longer than 5 seconds
unsetopt flowcontrol  # disable ^s from freezing the terminal

#
# history

HISTFILE="${XDG_DATA_HOME:-${HOME}/.local/share}/zsh/history"
HISTSIZE=10000
SAVEHIST=10000

setopt hist_ignore_all_dups # ignore dups including non-sequential ones
setopt share_history # share command history data between sessions
setopt hist_verify # load hist into command buffer rather than exec immediately

#
# term support

# make sure $TERM is installed
# if not, fall back on xterm-256color
infocmp "$TERM" > /dev/null 2>&1 || export TERM=xterm-256color

# set term title appropriately based on term type
# user@host:current_dir (current_command)
case "$TERM" in
  xterm*|rxvt*|screen*|alacritty*|foot)
    term_preexec () {
        printf '\e]0;%s (%s)\a' ${(%):-'%n@%m:%~'} "$1"
    }
    term_precmd () {
        printf '\e]0;%s\a' ${(%):-'%n@%m:%~'}
    }
    ;;
esac

#
# virtualenv

if [ -e /usr/local/bin/virtualenvwrapper_lazy.sh ]; then
    vew=/usr/local/bin/virtualenvwrapper_lazy.sh
elif [ -e /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh ]; then
    vew=/usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh
fi

if [ -n "$vew" ]; then
    export VIRTUAL_ENV_DISABLE_PROMPT=true
    export WORKON_HOME=~/.virtualenv/envs
    source $vew
fi

#
# draw a horizontal separator

function hr {
    printf "$bg[red]${(l:$COLUMNS:: :)}$reset_color\n"
    printf "$bg[yellow]${(l:$COLUMNS:: :)}\n"
    printf "$bg[green]${(l:$COLUMNS:: :)}\n"
    printf "$bg[cyan]${(l:$COLUMNS:: :)}\n"
    printf "$bg[blue]${(l:$COLUMNS:: :)}\n"
    printf "$bg[magenta]${(l:$COLUMNS:: :)}$reset_color\n"
}

#
# less

export LESS=-i