aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.profile
blob: 250653cb534461c6f950cc097eeb7938ffb33275 (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright (c) 2018 Egor Tensin <Egor.Tensin@gmail.com>
# This file is part of the "linux-home" project.
# For details, see https://github.com/egor-tensin/linux-home.
# Distributed under the MIT License.

if command -v vim > /dev/null 2>&1; then
    export EDITOR=vim
elif command -v nano > /dev/null 2>&1; then
    export EDITOR=nano
fi

path_export() {
    local path
    for path; do
        # Don't add paths with colons in them:
        case "$path" in
            *:*) continue ;;
        esac
        case "${PATH-}" in
            "$path")     continue ;;
            *":$path")   continue ;;
            "$path:"*)   continue ;;
            *":$path:"*) continue ;;
        esac
        export PATH="$path:${PATH-}"
    done
}

path_export "$HOME/.local/bin"

# -----------------------------------------------------------------------------
# Homebrew
# -----------------------------------------------------------------------------

brew_setup() {
    [ -x /opt/homebrew/bin/brew ] && \
        eval "$( /opt/homebrew/bin/brew shellenv )" && \
        prefix="$( brew --prefix )" && \
        path_export \
            "$prefix/opt/coreutils/libexec/gnubin" \
            "$prefix/opt/findutils/libexec/gnubin" \
            "$prefix/opt/gnu-sed/libexec/gnubin" \
            "$prefix/opt/grep/libexec/gnubin" \
            "$prefix/opt/python/libexec/bin"
}

brew_setup

# -----------------------------------------------------------------------------
# Ruby
# -----------------------------------------------------------------------------

# This is a half-assed way to automatically add your user's gem binary
# directory to $PATH (also setting GEM_HOME).

ruby_setup() {
    local user_dir
    local bin_dir

    command -v ruby > /dev/null 2>&1                   \
        && command -v gem > /dev/null 2>&1             \
        && user_dir="$( ruby -e 'puts Gem.user_dir' )" \
        && export GEM_HOME="$user_dir"                 \
        && bin_dir="$( ruby -e 'puts Gem.bindir' )"    \
        && path_export "$bin_dir"
}

# Deprecated in favour of using chruby/RVM/etc. for Ruby management.
#ruby_setup

chruby_setup() {
    local install_prefix="$HOME/.local"
    local share_dir="$install_prefix/share/chruby"
    [ -r "$share_dir/chruby.sh" ] && . "$share_dir/chruby.sh"
    [ -r "$share_dir/auto.sh"   ] && . "$share_dir/auto.sh"
}

chruby_setup

rbenv_setup() {
    local rbenv_init

    command -v rbenv > /dev/null && \
        rbenv_init="$( rbenv init - )" && \
        eval "$rbenv_init"
}

rbenv_setup

# -----------------------------------------------------------------------------
# Python
# -----------------------------------------------------------------------------

# This is a half-assed way to automatically add your user's pip binary
# directory to $PATH.

python_setup() {
    local python
    local user_base
    for python; do
        command -v "$python" > /dev/null 2>&1                 \
            && user_base="$( "$python" -m site --user-base )" \
            && path_export "$user_base/bin"
    done
}

python_setup python3 python

[ -r "$HOME/.pythonrc" ] && export PYTHONSTARTUP="$HOME/.pythonrc"

pyenv_setup() {
    local pyenv_init

    command -v pyenv > /dev/null && \
        pyenv_init="$( pyenv init - )" && \
        eval "$pyenv_init"
}

pyenv_setup

# -----------------------------------------------------------------------------
# Rust
# -----------------------------------------------------------------------------

path_export "$HOME/.cargo/bin"

# -----------------------------------------------------------------------------
# fzf
# -----------------------------------------------------------------------------

# Search directories and hidden files by default.
export FZF_DEFAULT_COMMAND='find -L . -\( -fstype dev -o -fstype proc -\) -prune -o -print 2> /dev/null'

command -v fd > /dev/null 2>&1 \
    && export FZF_DEFAULT_COMMAND='fd --follow --show-errors --hidden --no-ignore-vcs 2> /dev/null'

# -----------------------------------------------------------------------------
# nnn
# -----------------------------------------------------------------------------

# -A    Don't auto-enter directories.
# -e    Open text files in $EDITOR.
# -o    Only open on Enter, not on l.
export NNN_OPTS=Aeo
export NNN_PLUG='f:myfzcd'
export NNN_BMS="d:$HOME/Downloads;w:$HOME/workspace/personal"