blob: 690e4668f16acc38209bf15a4f68e905d48ac7d4 (
plain)
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
|
#!/bin/sh
KERNEL=$(uname -s)
# Aliases
alias e=\$VISUAL
## Replace vi and vim with neovim if installed
if [ -x "$(command -v nvim)" ]; then
alias vi='nvim'
alias vim='nvim'
fi
## Replace ls and tree with eza if installed
if [ -x "$(command -v eza)" ]; then
alias ls='eza --group-directories-first'
alias tree='eza --tree'
else
ls --color=auto > /dev/null 2>&1 && alias ls='ls --color=auto'
fi
## Colors
if [ -x "$(command -v dircolors)" ]; then
if [ -f ~/.dircolors ]; then
eval "$(dircolors ~/.dircolors)"
else
eval "$(dircolors)"
fi
fi
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias hexedit='hexedit --color'
alias minicom='minicom -c on'
## Some more ls aliases
alias ll='ls -l'
alias la='ls -Al'
# Easy to use copy/paste aliases for different platforms
if [ "$KERNEL" = "Linux" ]; then
alias ucopy='xclip -selection c'
alias upaste='xclip -selection clipboard -o'
elif [ "$KERNEL" = "Darwin" ]; then
alias ucopy='pbcopy'
alias upaste='pbpaste'
fi
# ex - archive extractor
# # usage: ex <file>
ex () {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
welcome_msg () {
if [ "$KERNEL" = "Linux" ]; then
DF_ARGS="-h -T -xtmpfs -xdevtmpfs"
if [ -x "$(command -v lsb_release)" ]; then
OS_DESCRIPTION="$(lsb_release -sd)"
# Manjaro has a weird lsb_release, compensate
[ "$OS_DESCRIPTION" = '"Manjaro Linux"' ] && OS_DESCRIPTION="Manjaro Linux $(lsb_release -sr) ($(lsb_release -sc))"
else
OS_DESCRIPTION="$(uname --operating-system)"
fi
elif [ "$KERNEL" = "Darwin" ]; then
DF_ARGS="-h -l"
OS_DESCRIPTION="$(system_profiler SPSoftwareDataType -detailLevel mini | grep -o "System Version: .*" | awk -F ': ' '{print $2}')"
fi
printf '\n'
printf ' \e[1mUser: \e[0;32m%s\e[0m\n' "$USER"
printf ' \e[1mHostname: \e[0;32m%s\e[0m\n' "$(uname -n)"
printf ' \e[1mOS: \e[0;32m%s\e[0m\n' "$OS_DESCRIPTION"
printf ' \e[1mKernel: \e[0;32m%s %s\e[0m\n' "$KERNEL" "$(uname -r)"
printf '\n'
printf ' \e[1mDisk usage:\e[0m\n'
printf '\n'
printf '%s\n' "$(eval df $DF_ARGS | sed 's/^/ /')"
printf '\n'
}
|