-
Notifications
You must be signed in to change notification settings - Fork 0
/
bashrc
165 lines (125 loc) · 4.16 KB
/
bashrc
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# .bashrc
[ -z "${PLATFORM}" ] && export PLATFORM=$(uname -s)
[ -f /etc/bashrc ] && . /etc/bashrc
tty=`ps -p $$ | tail -n +2 | grep -oE '[^ \/]+$'`
export PATH=${HOME}/.bin:${PATH}
export PATH=${HOME}/.local/bin:${PATH}
export PATH=${HOME}/local/nvim/bin:${PATH}
export PATH=${HOME}/.local/bin/lua-language-server/bin:${PATH}
export BASH_ENV=$HOME/.bashrc
# LS colors
if [ "$tty" = "busybox" ]; then
alias ls='ls --color=auto'
else
alias ls='ls -h --color=auto --group-directories-first'
alias grep='grep --color=always --exclude=*.o --exclude=*.a --exclude=*.obj --exclude=*.lib --exclude=*.elf --exclude=*.axf --exclude=*.map --exclude-dir=.svn --exclude-dir=.git'
fi
alias ll='ls -l'
alias la='ls -la'
LS_COLORS=$LS_COLORS:'no=00:di=1;35:'
export LS_COLORS
# clear alias
alias cl='clear'
# alias for bitbake
alias bb='bitbake'
# switching to neovim: alias vim to neovim only if it exists
if [ -n "$(which nvim)" ]; then
alias vim=nvim
alias vi=nvim
fi
# git helpers
source ~/.git-completion.bash
if [[ $(uname -s) =~ ^Linux ]] && [ ! -z "$(pgrep -x "i3")" ]; then
source ~/.config/i3/scripts/theme-autocomplete
fi
alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold yellow)%d%C(reset) %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(green)- %an%C(reset)'"
alias gs="git status"
alias gd="git diff"
alias git-store-credentials="git config credential.helper store"
alias lg='lazygit'
ga() {
FILES=`git status -s | grep --color=NEVER -e "\(.M\|??\)" | sed "s/^[[:space:]]*//g" | cut -d" " -f2 | fzf --reverse -m --no-info --height=20 --cycle` && git add $FILES
}
gco() {
git checkout $(git show-ref | cut -d" " -f2 | fzf)
}
alias cd..="cd .."
alias ..="cd .."
alias mk-ls='make -qpRr | grep --color=always -e "^[a-z].*:"'
alias d2u='find . -type f -print0 | xargs -0 dos2unix'
alias u2d='find . -type f -print0 | xargs -0 unix2dos'
fkill() {
local pid
pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
if [ "x$pid" != x ]; then
echo $pid | xargs kill -9
fi
}
# nnn configuration
# -----------------------------------------------------------------------------
nn() {
if [[ "${NNNLVL:-0}" -ge 1 ]]; then
echo "nnn is already running"
return
fi
export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
\nnn -Ae "$@"
if [ -f "$NNN_TMPFILE" ]; then
. "$NNN_TMPFILE"
rm -f "$NNN_TMPFILE" > /dev/null
fi
}
alias n="nn -A -e"
export NNN_BMS="u:/home/radu;d:/home/radu/documents;w:/home/radu/work"
export NNN_PLUG="s:switch-path"
export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export TERM='xterm-256color'
export EDITOR=nvim
# Prompt
# -----------------------------------------------------------------------------
get_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1='\u@\[\033[36m\]\h\[\033[32m\]`get_git_branch`\[\033[33m\] \w\[\033[00m\]\n\\$ '
# Fzf
# -----------------------------------------------------------------------------
export FZF_DEFAULT_OPTS='--height=40% --layout=reverse --border'
# Bookmark utility
# -----------------------------------------------------------------------------
sp() {
cd ${HOME}
[ -f ".bookmarks" ] && path="$(cat .bookmarks | fzf)"
if [ ! -z "$path" ]; then
cd $path
# n $path
else
cd - > /dev/null
fi
}
bp() {
local path="$(pwd)"
cd $HOME
if [ ! -f ".bookmarks" ]; then
echo "$path" > .bookmarks
else
local query="^${path}$"
local result=$(cat .bookmarks | grep "$query")
if [ -z "$result" ]; then
echo "$path" >> .bookmarks
fi
fi
cd - > /dev/null
}
# Exercism
# -----------------------------------------------------------------------------
if [ -f ~/.config/exercism/exercism_completion.bash ]; then
source ~/.config/exercism/exercism_completion.bash
fi
# Local settings: these bash settings are specific to each computer I use and
# therefore should not be published on the github
# -----------------------------------------------------------------------------
if [ -f ~/.local.conf ]; then
source ~/.local.conf
fi
alias luamake="/home/radu/.local/bin/lua-language-server/3rd/luamake/luamake"