parent
9ed4cea16c
commit
6665741686
@ -0,0 +1,20 @@
|
||||
# --- enable/disable this file ---
|
||||
SRC_ENABLED=true
|
||||
|
||||
case "$SRC_ENABLED" in
|
||||
1|true|yes|on) unset SRC_ENABLED ;; # enabled — clean up and continue
|
||||
*) unset SRC_ENABLED; return ;; # disabled — clean up and skip this file
|
||||
esac
|
||||
# ---------------------------------
|
||||
|
||||
# Colored man pages
|
||||
export LESS_TERMCAP_mb=$'\e[1;31m' # begin blinking — red (was green)
|
||||
export LESS_TERMCAP_md=$'\e[1;33m' # begin bold — yellow (was blue, headings)
|
||||
export LESS_TERMCAP_me=$'\e[0m' # end mode
|
||||
export LESS_TERMCAP_se=$'\e[0m' # end standout-mode
|
||||
export LESS_TERMCAP_so=$'\e[01;36m' # begin standout-mode — cyan (footer/status line, search hits)
|
||||
export LESS_TERMCAP_ue=$'\e[0m' # end underline
|
||||
export LESS_TERMCAP_us=$'\e[1;4;32m' # begin underline — green (was red)
|
||||
|
||||
export GROFF_NO_SGR=1
|
||||
|
||||
@ -0,0 +1,149 @@
|
||||
# --- enable/disable this file ---
|
||||
SRC_ENABLED=true
|
||||
|
||||
case "$SRC_ENABLED" in
|
||||
1|true|yes|on) unset SRC_ENABLED ;; # enabled — clean up and continue
|
||||
*) unset SRC_ENABLED; return ;; # disabled — clean up and skip this file
|
||||
esac
|
||||
# ---------------------------------
|
||||
|
||||
bash_pstree()
|
||||
{
|
||||
local root_pid="${1:-1}"
|
||||
local procdir pid key value name ppid idx
|
||||
|
||||
PIDS=()
|
||||
PPIDS=()
|
||||
NAMES=()
|
||||
idx=0
|
||||
|
||||
#
|
||||
# Build process table from /proc/*/status.
|
||||
#
|
||||
for procdir in /proc/[0-9]*; do
|
||||
[[ -d "$procdir" ]] || continue
|
||||
[[ -r "$procdir/status" ]] || continue
|
||||
pid="${procdir#/proc/}"
|
||||
name=""
|
||||
ppid=""
|
||||
while IFS=: read -r key value; do
|
||||
value="${value#"${value%%[![:space:]]*}"}"
|
||||
case "$key" in
|
||||
Name) name="$value" ;;
|
||||
PPid) ppid="$value" ;;
|
||||
esac
|
||||
done < "$procdir/status"
|
||||
[[ -n "$ppid" ]] || continue
|
||||
PIDS[$idx]="$pid"
|
||||
PPIDS[$idx]="$ppid"
|
||||
NAMES[$idx]="${name:-?}"
|
||||
idx=$((idx + 1))
|
||||
done
|
||||
|
||||
bash_pstree_set_chars
|
||||
bash_pstree_root "$root_pid"
|
||||
}
|
||||
|
||||
#
|
||||
# Pick UTF-8 box-drawing chars if the locale supports them, else
|
||||
# fall back to plain ASCII (works on any RHEL5 console/terminal).
|
||||
#
|
||||
bash_pstree_set_chars()
|
||||
{
|
||||
local charmap
|
||||
charmap=$(locale charmap 2>/dev/null)
|
||||
|
||||
if [[ "$charmap" == "UTF-8" ]]; then
|
||||
BPT_VERT="│ "
|
||||
BPT_TEE="├── "
|
||||
BPT_LAST="└── "
|
||||
else
|
||||
BPT_VERT="| "
|
||||
BPT_TEE="|-- "
|
||||
BPT_LAST="\`-- "
|
||||
fi
|
||||
}
|
||||
|
||||
bash_pstree_find_name()
|
||||
{
|
||||
local target="$1"
|
||||
local i
|
||||
for ((i = 0; i < ${#PIDS[@]}; i++)); do
|
||||
if [[ "${PIDS[$i]}" == "$target" ]]; then
|
||||
printf '%s' "${NAMES[$i]}"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Print numerically-sorted child PIDs of $1, one per line.
|
||||
#
|
||||
bash_pstree_children()
|
||||
{
|
||||
local parent="$1"
|
||||
local i list
|
||||
list=""
|
||||
for ((i = 0; i < ${#PIDS[@]}; i++)); do
|
||||
if [[ "${PPIDS[$i]}" == "$parent" ]]; then
|
||||
list="$list${PIDS[$i]}
|
||||
"
|
||||
fi
|
||||
done
|
||||
[[ -n "$list" ]] && printf '%s' "$list" | sort -n
|
||||
}
|
||||
|
||||
bash_pstree_root()
|
||||
{
|
||||
local pid="$1" name
|
||||
name=$(bash_pstree_find_name "$pid") || return
|
||||
printf '%s(%s)\n' "$name" "$pid"
|
||||
bash_pstree_show_children "$pid" ""
|
||||
}
|
||||
|
||||
#
|
||||
# $1 = parent pid, $2 = prefix accumulated so far
|
||||
#
|
||||
bash_pstree_show_children()
|
||||
{
|
||||
local parent="$1" prefix="$2"
|
||||
local child name last_line
|
||||
|
||||
local children
|
||||
children=$(bash_pstree_children "$parent")
|
||||
[[ -n "$children" ]] || return
|
||||
|
||||
last_line=$(printf '%s\n' "$children" | tail -n 1)
|
||||
|
||||
while IFS= read -r child; do
|
||||
[[ -n "$child" ]] || continue
|
||||
name=$(bash_pstree_find_name "$child") || continue
|
||||
if [[ "$child" == "$last_line" ]]; then
|
||||
printf '%s%s%s(%s)\n' "$prefix" "$BPT_LAST" "$name" "$child"
|
||||
bash_pstree_show_children "$child" "${prefix} "
|
||||
else
|
||||
printf '%s%s%s(%s)\n' "$prefix" "$BPT_TEE" "$name" "$child"
|
||||
bash_pstree_show_children "$child" "${prefix}${BPT_VERT}"
|
||||
fi
|
||||
done <<< "$children"
|
||||
}
|
||||
|
||||
#
|
||||
# Wrapper:
|
||||
#
|
||||
# pstree_compat
|
||||
# pstree_compat 1234
|
||||
#
|
||||
pstree_compat()
|
||||
{
|
||||
local root_pid="${1:-1}"
|
||||
if command -v pstree >/dev/null 2>&1; then
|
||||
pstree -p "$root_pid"
|
||||
else
|
||||
bash_pstree "$root_pid"
|
||||
fi
|
||||
}
|
||||
|
||||
alias pstree='pstree_compat'
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
# --- enable/disable this file ---
|
||||
SRC_ENABLED=false
|
||||
|
||||
case "$SRC_ENABLED" in
|
||||
1|true|yes|on) unset SRC_ENABLED ;; # enabled — clean up and continue
|
||||
*) unset SRC_ENABLED; return ;; # disabled — clean up and skip this file
|
||||
esac
|
||||
# ---------------------------------
|
||||
|
||||
if [ "$HOSTNAME" = "$HOMEHOST" ]; then
|
||||
# Nasourcujeme termclock
|
||||
. ~/.config/termclock.rc
|
||||
mman() {
|
||||
PID=$(xdotool getwindowpid "$(xdotool search --classname manualy | head -n1)")
|
||||
SESSION=$(qdbus6 "org.kde.konsole-$PID" | grep '^/Sessions/' | head -n1)
|
||||
qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.sendText $'\003'
|
||||
qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.runCommand "man $1"
|
||||
}
|
||||
cman() {
|
||||
PID=$(xdotool getwindowpid "$(xdotool search --classname manualy | head -n1)")
|
||||
SESSION=$(qdbus6 "org.kde.konsole-$PID" | grep '^/Sessions/' | head -n1)
|
||||
qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.sendText "q"
|
||||
qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.sendText $'\003'
|
||||
qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.sendText $'\014'
|
||||
qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.runCommand "TERM_CLOCK_COLOR='$TERM_CLOCK_COLOR' TERM_CLOCK_SYMBOL='$TERM_CLOCK_SYMBOL' TERM_CLOCK_SELF='$TERM_CLOCK_SELF' TERM_CLOCK_NO_DAY='$TERM_CLOCK_NO_DAY' $TERM_CLOCK_CMD -g3"
|
||||
}
|
||||
fi
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
# --- enable/disable this file ---
|
||||
SRC_ENABLED=true
|
||||
|
||||
case "$SRC_ENABLED" in
|
||||
1|true|yes|on) unset SRC_ENABLED ;; # enabled — clean up and continue
|
||||
*) unset SRC_ENABLED; return ;; # disabled — clean up and skip this file
|
||||
esac
|
||||
# ---------------------------------
|
||||
|
||||
|
||||
Loading…
Reference in new issue