-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshrc
121 lines (99 loc) · 2.91 KB
/
shrc
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
#!/bin/sh
# Please don't use /bin/bash in your scripts, make POSIX shell scripts
# __
# ___ / / ________
# _(_-</ _ \/ __/ __/ Made by:
# (_)__/_//_/_/ \__/ By_JumperX4
#
# Set default path (override everything)
PATH=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/games:/usr/local/games:$HOME/.local/bin:$HOME/go/bin
#
# Prompt
#
# Set prompt
PS1=$(
printf "$ "
if [ "${PWD#$HOME}" != "$PWD" ]; then
printf "~${PWD#$HOME}"
else
printf "$PWD"
fi
printf "> "
)
# Set prompt at every cd using an alias
function _cd {
cd "$@"
PS1=$(
printf "\$ "
if [[ "${PWD#$HOME}" != "$PWD" ]]; then
printf "~${PWD#$HOME}"
else
printf "$PWD"
fi
printf "> "
)
}
alias cd=_cd
#
# Variables
#
PATH="$PATH:$HOME/.local/bin" # Use the system's default path, then add some other places for extra commands.
SYSTEMD_PAGER="" # I don't want systemd to open logs in a pager when i'm on a system running systemd.
EDITOR="emacs -nw" # Emacs is my favorite text editor, some prefers to use another text editor but I like that one.
PAGER=less # I use less as pager, it just works.
# Autodetect the number of CPU threads that should be used to compile.
case "$(uname -s)" in
FreeBSD|OpenBSD)
cpunum=$(sysctl -n hw.ncpu)
;;
Linux)
cpunum=$(nproc)
;;
esac
case "$cpunum" in
1|2)
export MAKEFLAGS="-j $cpunum"
;;
3|4|5)
export MAKEFLAGS="-j $((cpunum-1))"
;;
6|7)
export MAKEFLAGS="-j $((cpunum-2))"
;;
7|8|9|10|11)
export MAKEFLAGS="-j $((cpunum-3))"
;;
*)
export MAKEFLAGS="-j $((cpunum-cpunum/8))"
esac
QT_QPA_PLATFORMTHEME=qt5ct # QT5 Theme engine.
TERMINAL=xterm-256color # I use XTerm, let whatever needs that variable be aware of that.
# Options/modes
set -o posix # I want my shell to be posix compliant
set -o emacs # Emacs is my favourite text editor
#
# Aliases
#
# Coloration in commands, replace some commands with themselves but with arguments to enable colors
alias ip="ip -c"
alias grep="grep --color"
# ls related aliases
alias ls="ls -ah --color" # List all the files in an human-readable way with coloration.
alias l="ls -ahl --color" # Same as above, but instead display one file per line in a detailed way.
# Non-categorized aliases
alias h="fc -l | grep" # Search in history
# Execute command number X from history
alias vi="emacs -nw" # Replace the vi command with emacs.
alias dvi="doas emacs -nw" # Set dvi to emacs as root.
alias clr="clear" # Use "clr" to clear the terminal, this is shorter.
alias x="exit" # Use "x" to exit, this is shorter.
#
# Autostart
#
# Run X11 if in the first TTY. Supports GNU/Linux, FreeBSD and OpenBSD. Not tested on others
if [ "$(tty)" = "/dev/tty1" ] || [ "$(tty)" = "/dev/ttyv0" ] || [ "$(tty)" = "/dev/ttyC0" ]; then
dbus-launch startx -- -nolisten tcp
fi
# Display a fortune cookie told by a cow
fortune | cowsay
# End.