aboutsummaryrefslogtreecommitdiffstats
path: root/ksh/.kshrc
blob: b8f8648c0fc4b4176cc630eaea9abd7ffb9027bf (plain) (blame)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# .kshrc
#
# note: this file is executed by interactive non-login shell
#       if it needs to execute for login shells too (i.e. virtual
#       tty) add export ENV=$HOME/.kshrc to .profile

LC_ALL="en_US.UTF-8"
# This PS1 is completed at the end, allowing statuses to be included between the directory and closing $
PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]"
END_PS1="\$\[\e[m\] "
# This is the original PS1
#PS1="[\u@\[\e[38;5;148m\]\h\[\e[m\]:\[\e[36m\]\W\[\e[m\]\[\e[m\]]\[\e[m\]\$\[\e[m\] "
PATH="${HOME}/bin:${HOME}/.local/bin:${PATH}"

# OpenBSD
# FreeBSD
# Darwin
# Linux
OS_NAME=`uname`

## Shell History
export HISTSIZE=99999
export HISTFILE=$HOME/.ksh_history
export HISTCONTROL="ignoredupes:ignorespace"

export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"

## Telemetry
# Disable various telemetry
export SAM_CLI_TELEMETRY=0

## Warpdir
WD=`which warpdir 2> /dev/null`
if [ -x "$WD" ]; then
    wd() {
        output=$(warpdir $@)
        status_code=$?
        if [[ $status_code -eq 0 ]]; then
            cd "$output"
        elif [[ "$output" != "" ]]; then
            echo "$output"
        fi
        unset output
        unset status_code
    }
fi

## FZF
FZF=`which fzf 2> /dev/null`
if [ -x "$FZF" ]; then
    # fzf does not have first class ksh support.
    function fzf-histo {
        RES=$(fzf --tac --no-sort -e < $HISTFILE)
        test -n "$RES" || exit 0
        eval "$RES"
    }

    # space so it isn't saved in the history
    bind -m ^R=' fzf-histo'^J
fi


## Python
__workon() {
    source ~/.virtualenvs/$1/bin/activate
}
__mkvirtualenv() {
    python -mvenv ~/.virtualenvs/$1
    . $HOME/.virtualenvs/$1/bin/activate
}
alias workon=__workon
alias mkvirtualenv=__mkvirtualenv

## Go

if [ -d "$HOME/go/bin" ]; then
    export PATH=$HOME/go/bin:$PATH
fi

## direnv
DIRENV=`which direnv 2> /dev/null`
if [ -x "$DIRENV" ]; then
    # https://github.com/direnv/direnv/issues/873
    refresh_direnv() {
        eval "$("$DIRENV" export bash | sed 's@=\$'\''@='\''@g')"
    }

    direnv() {
        "$DIRENV" "$@"
        refresh_direnv
    }

    cd() {
        builtin cd "$@"
        refresh_direnv
    }
fi

## nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

# Close off the PS1 with the $
export PS1=${PS1}${END_PS1}