-
Notifications
You must be signed in to change notification settings - Fork 0
/
powerbash.bash-theme
83 lines (81 loc) · 3.36 KB
/
powerbash.bash-theme
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
#!/usr/bin/env bash
# Bash theme that looks like powerlevel10k
# function to get git branch for ps1 (made as an alternative to git-prompt.sh)
__pbash_installation_dir=$(dirname "${BASH_SOURCE[0]}")
[ -d "${__pbash_installation_dir}/modules" ] && for file in "${__pbash_installation_dir}/modules"/*; do [ -f "$file" ] && source "$file";__pbash_core_modules_list+=" $(basename "$file" .sh)"; done
[ -d "${__pbash_installation_dir}/commands" ] && for file in "${__pbash_installation_dir}/commands"/*; do [ -f "$file" ] && source "$file";__pbash_core_commands_list+=" $(basename "$file" .sh)"; done
__pbash_command_prefix="$(fc2 6)pbash $(fc2 255)❯"
__pbash_current_version="2.2.3"
if [[ "$__pbash_shorten_directory" != "false" ]]; then
PROMPT_DIRTRIM=4
fi
# Distro checker (for the distro's logo in the prompt)
. /etc/os-release 2>/dev/null || NAME=$(uname)
case "$NAME" in
"Arch Linux") export distro_logo="";;
"Artix Linux") export distro_logo="";;
"Ubuntu") export distro_logo="";;
"Manjaro Linux") export distro_logo="";;
"Alpine Linux") export distro_logo="";;
"Debian GNU/Linux") export distro_logo="";;
"Devuan GNU/Linux") export distro_logo="";;
"AlmaLinux") export distro_logo="";;
"Fedora Linux") export distro_logo="";;
"Gentoo") export distro_logo="";;
"CentOS Linux") export distro_logo="";;
"elementary OS") export distro_logo="";;
"Rocky Linux") export distro_logo="";;
"Kali GNU/Linux") export distro_logo="";;
"Void") export distro_logo="";;
"Pop!_OS") export distro_logo="";;
"FreeBSD") export distro_logo="";;
"OpenBSD") export distro_logo="";;
"Darwin") export distro_logo="";;
"Vanilla OS") export distro_logo="";;
"NixOS") export distro_logo="";;
"ArcoLinux") export distro_logo="";;
"Linux Mint") export distro_logo="";;
"Kubuntu") export distro_logo="";;
"Solus") export distro_logo="";;
"Zorin OS") export distro_logo="";;
"Parabola") export distro_logo="";;
"Slackware") export distro_logo="";;
"Red Hat Enterprise Linux") export distro_logo="";;
*) export distro_logo="";;
esac
# Command handler
pbash() {
case $1 in
help)
# List files in the commands/ directory without extensions
command_files=$(ls ${__pbash_installation_dir}/commands/*.sh && ls ${__pbash_modules_userconfig_path}/commands/*.sh 2>/dev/null)
command_names=""
for file in $command_files; do
command_name=$(basename "$file" .sh)
command_names+=" $command_name"
done
printf "${__pbash_command_prefix} commands:$(fc2 4)$command_names\n\e[m"
if [[ -n $2 ]]; then
command_help_variable="__pbash_commands_${2}_help"
if declare -p "$command_help_variable" &>/dev/null; then
printf "\n${__pbash_command_prefix} $2 help:\n"
printf "%s\e[m" "${!command_help_variable}"
else
printf "\n${__pbash_command_prefix} $(fc2 1)no help available for '$2'\n\e[m"
fi
else
printf "\n${__pbash_command_prefix} type $(fc2 4)pbash help [command] $(fc2 255)to get more help about a command\n\e[m"
fi
;;
*)
# Check if the command is in the combined command list
if [[ " $__pbash_core_commands_list $__pbash_user_commands_list " == *" $1 "* ]]; then
# Execute the command function
"pbash_$1" ${@:2}
else
printf "${__pbash_command_prefix} $(fc2 1)invalid command, try pbash help\n\e[m"
fi
;;
esac
}
source $__pbash_configuration_path 2>/dev/null