-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.profile
105 lines (95 loc) · 3.64 KB
/
.profile
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
PATH=/usr/local/bin:/usr/local/sbin:$PATH
# TMUX
export SHELL=$( which bash )
# Git values
export GIT_PS1_SHOWUNTRACKEDFILES=true
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWCOLORHINTS=true
# Bash colors
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export LS_COLORS='di=1;36:ln=1;35:so=1;32:pi=1;33:ex=1;31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=34;43'
# Use vim as the default editor
export EDITOR=vim
# This file's location
export PROFILE_LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Ignore duplicates in bash history
export HISTCONTROL="erasedups:ignoreboth"
# Do not put those commands in command history
export HISTIGNORE="ls:ll:pwd"
# Add time to history command
export HISTTIMEFORMAT="%F %T "
# Record the history right away (instead of at the end of the session)
export PROMPT_COMMAND='history -a'
# Correct minor spelling mistakes
shopt -s cdspell
shopt -s dirspell
[[ ! -f ~/.inputrc ]] && echo "set completion-ignore-case On" >> ~/.inputrc
# Functions included in this library
for f in $PROFILE_LOCATION/functions/*.sh; do
[[ ! -x $f ]] && source $f
done
PATH=$(find $PROFILE_LOCATION/functions -maxdepth 2 -type d | tr '\n' ':' | sed 's/:$//'):~/.bin:$PATH
# M1 Homebrew
if [[ $( uname -p ) == "arm" ]]; then
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
fi
# OSX bash completion via homebrew
if hash brew 2>/dev/null; then
[ -r $(brew --prefix)/etc/bash_completion ] && . $(brew --prefix)/etc/bash_completion
[ -r $(brew --prefix)/share/bash-completion/bash_completion ] && . $(brew --prefix)/share/bash-completion/bash_completion
[ -r $(brew --prefix)/etc/profile.d/bash_completion.sh ] && . $(brew --prefix)/etc/profile.d/bash_completion.sh
[ -r $(brew --prefix)/opt/git/etc/bash_completion.d/git-prompt.sh ] && . $(brew --prefix)/opt/git/etc/bash_completion.d/git-prompt.sh
fi
# *NIX bash completion
if ! shopt -oq posix; then
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
[ -r /etc/bash_completion ] && . /etc/bash_completion
fi
# General aliases
alias ..="cd .."
alias ...="cd ../.."
ls --color &>/dev/null && alias ls="ls --color"
alias ll="ls -lah"
hash eza 2>/dev/null && alias eza="eza -la"
hash tree 2>/dev/null && alias tree="tree -C"
function mkcd() {
## Shell scripts are run in a subshell, so the cd command would never work in an external function
mkdir -p "$1" && cd "$_"
}
# MacOS-specific aliases
if [[ "$OSTYPE" == "darwin"* ]]; then
alias prev="open -a Preview"
alias screensaver="open -a ScreenSaverEngine"
fi
# Machine-specific .profile
for f in ~/.profile.*; do
[[ -f $f ]] && source $f
done
# direnv
# https://direnv.net/
hash direnv 2>/dev/null && eval "$( direnv hook bash )"
# fuzzy finder
# https://github.com/junegunn/fzf
hash fzf 2>/dev/null && eval "$( fzf --bash )"
# thefuck
# https://github.com/nvbn/thefuck
hash thefuck 2>/dev/null && eval $( thefuck --alias )
term=$( ps -p $( ps -p $$ -o ppid= ) -o args= )
# Set PS1 with git if available
if [[ ${term} == *"Hyper"* ]]; then
export PS1="\u \$ "
else
ps1_var="\[\e[1m\]\u"
hash __git_ps1 2>/dev/null && ps1_var="$ps1_var\$(__git_ps1)"
export PS1="$ps1_var \$ \[\e[0m\]"
fi
# Set tab title to current dir if not already supported by terminal emulator
if [[ ${term} == "login -pf"* ]]; then
export PROMPT_COMMAND="$PROMPT_COMMAND"'; set-title $( dirs -0 )'
fi