Repository navigation
Expand file tree
/
Copy pathbashrc
More file actions
133 lines (110 loc) · 3.64 KB
/
Copy pathbashrc
File metadata and controls
133 lines (110 loc) · 3.64 KB
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
#!/usr/bin/env bash
# A common 'main' script file to include across multiple machines.
# shellcheck source=./aliases
. ~/script/aliases
# shellcheck source=./functions
. ~/script/functions
# shellcheck source=./completion/rules
. ~/script/completion/rules
if ! ((KEEP_PS1)); then
PS1='\W$ '
fi
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color|xterm-ghostty) color_prompt=yes;;
esac
if [ "$color_prompt" = yes ]; then
if [[ "$OSTYPE" =~ ^darwin ]]; then
PS1='\[\033[01;32m\]mac\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
fi
else
if [[ "$OSTYPE" =~ ^darwin ]]; then
PS1='\[\033[01;32m\]mac\[\033[00m\]:\w\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
fi
unset color_prompt
# Try local paths.
# pip install --user does use `~/.local/bin`
export PATH="$PATH:$HOME/bin:$HOME/.local/bin"
# Scripts which should work on any Unix flavour.
export PATH="$PATH:$HOME/script/unix"
if [[ "$OSTYPE" =~ ^darwin ]]; then
# Set up Homebrew on Macs
if [ -e /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# Set up pyenv if it's around
if command -v pyenv > /dev/null; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
fi
else
# Load Linux scripts if not on a Mac
export PATH="$PATH:$HOME/script/linux"
# Set up pyenv if it's around
if [ -f "$HOME/.pyenv/bin/pyenv" ]; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init - bash)"
fi
fi
# Tell Windows Terminal the current directory (OSC 9;9) so duplicated tabs/panes open here
if [[ -n "$WSL_DISTRO_NAME" && -n "$WT_SESSION" ]]; then
__wt_osc9_9() { printf '\e]9;9;%s\e\\' "$(wslpath -w "$PWD")"; }
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND; }__wt_osc9_9"
fi
# Disable Ctrl+S and Ctrl+Q behaviour on Macs so we can keybind those keys.
# This will stop suspend and resume commands for the terminal.
if [[ "$OSTYPE" =~ ^darwin ]]; then
stty -ixon
fi
# Set up Go, if available
if [ -z "$GOROOT" ]; then
if command -v go &> /dev/null; then
GOPATH=$(go env GOPATH)
GOROOT=$(go env GOROOT)
export GOPATH
export GOROOT
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
fi
fi
# Set up Rust, if available.
if [ -d ~/.cargo ]; then
export PATH="$PATH:$HOME/.cargo/bin"
# shellcheck disable=SC1091
source "$HOME/.cargo/env"
fi
# Set up nvm, if available.
if command -v nvm &> /dev/null; then
export NVM_DIR="$HOME/.nvm"
# shellcheck disable=SC1091
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# shellcheck disable=SC1091
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi
# Make git accept commit messages generated for merges, so there's less
# typing involved.
export GIT_MERGE_AUTOEDIT=no
# Stop Ctrl+D from closing the terminal.
set -o ignoreeof
# Make history ten times as large as it is by default.
export HISTSIZE=10000
export HISTFILESIZE=20000
# Use Chromium for Karma tests.
export CHROME_BIN=/usr/bin/chromium-browser
# Give Node more RAM
export NODE_OPTIONS="--max_old_space_size=4096"
shopt -s globstar
# Set up the gpg agent.
GPG_TTY="$(tty)"
export GPG_TTY