-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
180 lines (162 loc) · 4.71 KB
/
bashrc
File metadata and controls
180 lines (162 loc) · 4.71 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
if [ `command -v starship` ] ; then
eval "$(starship init bash)"
fi
if [ `command -v fzf` ] ; then
eval "$(fzf --bash)"
fi
# VARIABLES
if [ `command -v nvim` ] ; then
export EDITOR="/usr/bin/nvim"
export VISUAL="/usr/bin/nvim"
fi
export HISTCONTROL=ignoreboth
export HISTSIZE=2000
export GOPATH="${HOME}/.go"
if [ `command -v bat` ] ; then
export BAT_STYLE=plain
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export MANROFFOPT="-c"
fi
# SET LS_COLORS
eval "$(dircolors)"
export LS_COLORS="$LS_COLORS:ow=1;31;102:"
# ALIASES
alias h='history'
alias j='jobs -l'
alias g='git '
alias s='status '
alias a='add '
alias ip='ip --color=auto'
alias ls='ls --color=auto'
alias ll='ls --color=auto -lh'
alias la='ls --color=auto -lha'
alias l.='ls --color=auto -a'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias icat='kitty +kitten icat'
alias pingg='ping 8.8.8.8'
alias mountu='sudo mount -o uid=$USER,gid=users,fmask=113,dmask=002'
alias gdisksync='rclone sync /home/jirka/Music gdisk:/Music && rclone sync /home/jirka/Documents gdisk:/Documents && rclone sync /home/jirka/Pictures/Pictures gdisk:/Pictures/Pictures'
alias setEnv='export $(grep -v "^#" .env | xargs -d "\n")'
alias unsetEnv='unset $(grep -v "^#" .env | sed -E "s/(.*)=.*/\1/" | xargs -d "\n")'
alias vim='nvim'
if [ `command -v cargo` ] ; then
alias cc='clear && cargo check'
alias cr='cargo run'
alias ct='cargo test'
alias ccc='clear && cargo clippy'
fi
alias myIP='curl ifconfig.me && echo ""'
if [ `command -v nvim` ] ; then
alias view='nvim -R'
alias vim='nvim'
if [ `command -v fzf` ] ; then
alias nfzf='fzf --preview "bat --color=always --style=numbers --line-range=:500 {}" --print0 | xargs -0 -o nvim'
fi
fi
if [ `command -v fzf` ] ; then
alias pfzf='fzf --preview "bat --color=always --style=numbers --line-range=:500 {}"'
fi
# FUNCTIONS
testColors() {
MODULUS="${1:-16}"
if ! [[ "$MODULUS" =~ ^[0-9]+$ ]] ; then
echo "Parameter must be a number."
return 1
fi
for CODE in {000..255} ; do
echo -en "\e[30;48;5;${CODE}m ${CODE} "
if [ `expr 16 - 1` -eq `expr ${CODE} % 16` ] ; then
echo ""
fi
done
echo -en "\e[0m"
}
testFonts() {
echo -e "none: Žluťoučký kůň pěl šílené dábelské ódy."
echo -e "\e[1mbold: Žluťoučký kůň pěl šílené dábelské ódy.\e[0m"
echo -e "\e[3mitalic: Žluťoučký kůň pěl šílené dábelské ódy.\e[0m"
echo -e "\e[3m\e[1mbold italic: Žluťoučký kůň pěl šílené dábelské ódy.\e[0m"
echo -e "\e[4munderline: Žluťoučký kůň pěl šílené dábelské ódy.\e[0m"
echo -e "\e[9mstrikethrough: Žluťoučký kůň pěl šílené dábelské ódy.\e[0m"
echo -e "\e[31mcolored: Žluťoučký kůň pěl šílené dábelské ódy.\e[0m"
echo -e "special characters: @ # & + $ % ^ * ( ) [ ] { }"
echo -e "lignatures: ft fi fj -> :: </tag> || &&"
}
git() {
case "$1" in
"squash")
if [ "$#" -ne 2 ] ; then
echo "Set number of local commits to squash."
return
fi
command git reset --soft "HEAD~$2" && git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
;;
"cm")
command git commit -m "${@:2}" ;;
"all")
if [ "$#" -gt 3 ] ; then
echo "Too many arguments."
return
fi
DEPTH="2"
FIND_PATH="."
for ARG in "${@:2}" ; do
if [[ "$ARG" == "-"* ]] ; then
DEPTH="${ARG:1}"
else
FIND_PATH="$ARG"
fi
done
DEPTH=$(("$DEPTH" + 1))
WORKDIR="$PWD"
for REPOSITORY in `find "$FIND_PATH" -maxdepth "$DEPTH" -mindepth 1 -type d -name ".git"` ; do
DIRNAME="$(dirname $REPOSITORY)"
echo "$DIRNAME"
cd "$DIRNAME"
command git status -s
cd "$WORKDIR"
done
;;
*)
command git "$@" ;;
esac
}
function f {
find . -name "*${1}*" | tee >(xsel -ib)
}
function fname {
find . -name "${1}*" | tee >(xsel -ib)
}
function fe {
find . -name "${1}" | tee >(xsel -ib)
}
function bhelp {
local output
local ret_code
output=$("$@" -h 2> /dev/null)
if [ $? -ne 0 ] ; then
output=$("$@" --help 2> /dev/null)
fi
ret_code=$?
bat -l help <<< "$output"
return $ret_code
}
# BEGIN_KITTY_SHELL_INTEGRATION
if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; then
source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
fi
# END_KITTY_SHELL_INTEGRATION
if [ -f "$HOME/.aveco-info/scripts/bashrcAveco.sh" ] ; then
source $HOME/.aveco-info/scripts/bashrcAveco.sh
fi