-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
161 lines (134 loc) Β· 4.93 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
#!/bin/bash
# This script is used to configure the terminal
# for the Git Bash shell on Windows.
# Configure oh-my-posh theme
configure_oh_my_posh() {
eval "$(oh-my-posh init bash --config ~/AppData/Local/Programs/oh-my-posh/themes/dracula.omp.json)"
}
# Configure LS_COLORS
configure_ls_colors() {
local color_configs=(
"di=38;5;255" # Directory: White
"*.sh=38;5;222" "*.bat=38;5;172"
"*.vimrc=38;5;13" "*.viminfo=38;5;13" "*.vim=38;5;13"
"*.gitconfig=38;5;13" "*.bashrc=38;5;13" "*.bash_profile=38;5;13" "*.bash_history=38;5;13"
"*.py=38;5;203" "*.csv=38;5;156" "*.ipynb=38;5;184" "*.dart=38;5;51"
"*.lua=38;5;81" "*.cpp=38;5;81" "*.cs=38;5;46" "*.go=38;5;81"
"*.php=38;5;81" "*.css=38;5;41" "*.html=38;5;178" "*.java=38;5;74"
"*.js=38;5;74" "*.ts=38;5;115" "*.json=38;5;178" "*.xml=38;5;178"
"*.yaml=38;5;178" "*.yml=38;5;178"
"*.txt=38;5;253" "*.md=38;5;184"
)
for config in "${color_configs[@]}"; do
LS_COLORS=$LS_COLORS":$config"
done
export LS_COLORS
export GCC_COLORS='error=31:warning=35:note=36:caret=32:locus=01:quote=01'
}
# Set up aliases
set_aliases() {
alias cls='clear'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ls='ls --color=auto'
alias cd..='cd ..'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias mkdir='mkdir -pv'
alias h='history'
alias j='jobs -l'
alias df='df -h'
alias vi='nvim'
alias ls='ls_with_icons'
}
# Convert size to human-readable format
human_readable_size() {
local size=$1
local div=1
local unit='Byte'
if ((size >= 1073741824)); then
div=1073741824
unit='GB'
elif ((size >= 1048576)); then
div=1048576
unit='MB'
elif ((size >= 1024)); then
div=1024
unit='KB'
fi
local result=$(( (size * 100 + div / 2) / div ))
printf "%d.%02d %s" $((result / 100)) $((result % 100)) "$unit"
}
# Display icons and details for folders and files
ls_with_icons() {
local file_icons=(
# Programming and script languages
"sh:π:222" "bash:π:222" "zsh:π:222"
"py:π:203" "pyc:π:203" "pyo:π:203" "pyd:π:203"
"js:β¨:74" "ts:π·:115" "jsx:βοΈ:74" "tsx:π·βοΈ:115"
"cs:πΉοΈ:46" "csx:π»:46"
"java:β:74" "class:β:74" "jar:β:74"
"c:βοΈ:81" "cpp:βοΈ:81" "h:βοΈ:81" "hpp:βοΈ:81"
"go:πΉ:81"
# File cαΊ₯u hΓ¬nh vΓ hα» thα»ng
"json:βοΈ:178" "yaml:βοΈ:178" "yml:βοΈ:178"
"toml:βοΈ:178" "ini:βοΈ:178" "conf:βοΈ:178"
"cfg:βοΈ:178" "rc:βοΈ:178"
"gitignore:π:240" "gitattributes:π:240"
# File dα»― liα»u
"csv:π:156" "tsv:π:156"
"sqlite:ποΈ:25" "db:ποΈ:25"
# Markup and styling languages
"html:π:178" "css:π¨:42" "xml:π°:178"
"md:π:184"
# Office documents
"doc:π:27" "xls:π:28" "ppt:π:166" "pdf:π:160"
# Media files
"jpg:πΌοΈ:140" "png:πΌοΈ:140" "gif:πΌοΈ:140"
"mp3:π΅:135" "wav:π΅:135" "mp4:π¬:135"
# Archives
"zip:π¦:172" "rar:π¦:172" "7z:π¦:172" "tar:π¦:172"
"gz:π¦:172" "bz2:π¦:172" "xz:π¦:172"
# Executables
"exe:β‘:40" "msi:β‘:40" "bat:β‘:40" "cmd:β‘:40"
"app:β‘:40" "dmg:β‘:40"
# Miscellaneous
"txt:π:253"
"log:π:248"
)
printf "%-12s %-12s %-10s %-22s %s\n" "Permissions" "Size" "User" "Modified" "Name"
printf "%s\n" "============|=============|==========|======================|===================="
for item in *; do
local stat_info=$(stat -c "%A %s %U %y" "$item")
read -r perms size user modified <<< "$stat_info"
modified=$(date -d "$modified" "+%Y-%m-%d %H:%M")
if [ -d "$item" ]; then
printf "%-12s %-12s %-10s %-22s \033[1;255mπ %s\033[0m\n" "$perms" "-" "$user" "$modified" "$item"
elif [ -f "$item" ]; then
readable_size=$(human_readable_size $size)
ext="${item##*.}"
icon="π"
color="37"
for file_icon in "${file_icons[@]}"; do
IFS=':' read -r ext_match icon_match color_match <<< "$file_icon"
if [ "$ext" = "$ext_match" ]; then
icon="$icon_match"
color="$color_match"
break
fi
done
printf "%-12s %-12s %-10s %-22s \033[1;${color}m%s %s\033[0m\n" "$perms" "$readable_size" "$user" "$modified" "$icon" "$item"
fi
done
}
# Main function to run all configurations
main() {
configure_oh_my_posh
configure_ls_colors
set_aliases
bind 'set bell-style none'
}
# Run the main function
main