mirror of
https://github.com/gwebu-team/profile.d.git
synced 2025-12-07 11:55:48 +00:00
Fixing VENV again...
Updated .pre-commit-config.yaml
This commit is contained in:
parent
dc39105663
commit
affb7ae553
4 changed files with 44 additions and 15 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.5.0
|
rev: v6.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
args: [ '--maxkb=64' ]
|
args: [ '--maxkb=64' ]
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,5 @@ Unless explicitly stated in the file itself, the license is [The Unlicense](http
|
||||||
## Automation
|
## Automation
|
||||||
|
|
||||||
To update the RPM changelog run ./changelog.sh
|
To update the RPM changelog run ./changelog.sh
|
||||||
|
|
||||||
|
Type `make` to see the available targets (dist, rpm, podman_rpm, changelog, clean).
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@
|
||||||
# alternatively write to the Free Software Foundation, Inc.,
|
# alternatively write to the Free Software Foundation, Inc.,
|
||||||
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
# z-ps-twtty-7.sh - Nice bash prompt and history archiver
|
||||||
|
# by Doncho Gunchev <dgunchev@gmail.com>, 2025-11-02 16:27:00 EET
|
||||||
|
# Improve python virtual environments support.
|
||||||
|
#
|
||||||
# z-ps-twtty-7.sh - Nice bash prompt and history archiver
|
# z-ps-twtty-7.sh - Nice bash prompt and history archiver
|
||||||
# by Doncho Gunchev <dgunchev@gmail.com>, 2024-01-27 15:58 EET
|
# by Doncho Gunchev <dgunchev@gmail.com>, 2024-01-27 15:58 EET
|
||||||
# Show PIPESTATUS instead of just $?. Cleanup.
|
# Show PIPESTATUS instead of just $?. Cleanup.
|
||||||
|
|
@ -52,7 +56,8 @@ if [ "$PS1" ] ; then # interactive shell detection
|
||||||
# Log the logout event.
|
# Log the logout event.
|
||||||
function prompt_command_exit() {
|
function prompt_command_exit() {
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
local now=$(date --rfc-3339=ns 2> /dev/null || date -Iseconds)
|
local now
|
||||||
|
now=$(date --rfc-3339=ns 2> /dev/null || date -Iseconds)
|
||||||
local HistFile
|
local HistFile
|
||||||
HistFile="$HOME/bash_history/$(date '+%Y-%m/%Y-%m-%d')"
|
HistFile="$HOME/bash_history/$(date '+%Y-%m/%Y-%m-%d')"
|
||||||
mkdir -p "${HistFile%/*}"
|
mkdir -p "${HistFile%/*}"
|
||||||
|
|
@ -61,10 +66,12 @@ function prompt_command_exit() {
|
||||||
|
|
||||||
# Executed before each prompt. Fill the variables needed by PS1 here.
|
# Executed before each prompt. Fill the variables needed by PS1 here.
|
||||||
function prompt_command() {
|
function prompt_command() {
|
||||||
local now=$(date --rfc-3339=ns 2> /dev/null || date -Iseconds)
|
local now
|
||||||
|
now=$(date --rfc-3339=ns 2> /dev/null || date -Iseconds)
|
||||||
|
|
||||||
# Manage the history
|
# Manage the history
|
||||||
local HistFile="$HOME/bash_history/$(date '+%Y-%m/%Y-%m-%d')"
|
local HistFile
|
||||||
|
HistFile="$HOME/bash_history/$(date '+%Y-%m/%Y-%m-%d')"
|
||||||
mkdir -p "${HistFile%/*}"
|
mkdir -p "${HistFile%/*}"
|
||||||
|
|
||||||
if [ -z "$my_LoginTime" ]; then
|
if [ -z "$my_LoginTime" ]; then
|
||||||
|
|
@ -78,23 +85,25 @@ function prompt_command() {
|
||||||
# Add all the accessories below ...
|
# Add all the accessories below ...
|
||||||
my_D="$(date '+%Y-%m-%d %H:%M:%S')"
|
my_D="$(date '+%Y-%m-%d %H:%M:%S')"
|
||||||
# This is for string size calculations only. The variable my_P is set, see PROMPT_COMMAND below.
|
# This is for string size calculations only. The variable my_P is set, see PROMPT_COMMAND below.
|
||||||
|
if [ -z "$my_P" ]; then my_P="ERROR"; fi # make shellcheck happy.
|
||||||
local prompt="--($my_D, Err ${my_P[*]}, $my_TTY)---($PWD)--"
|
local prompt="--($my_D, Err ${my_P[*]}, $my_TTY)---($PWD)--"
|
||||||
|
|
||||||
if [ -n "${VIRTUAL_ENV:-}" ] && [ -n "$_OLD_VIRTUAL_PS1" ]; then
|
if [ -n "${VIRTUAL_ENV:-}" ] && [ -n "$_OLD_VIRTUAL_PS1" ]; then
|
||||||
if [ -n "$VIRTUAL_ENV_PROMPT" ]; then
|
if [ -n "$VIRTUAL_ENV_PROMPT" ]; then
|
||||||
my_VENV="${VIRTUAL_ENV_PROMPT%) }"
|
my_VENV="${VIRTUAL_ENV_PROMPT%\ }"
|
||||||
my_VENV="${my_VENV%) }"
|
my_VENV="${my_VENV%\)}"
|
||||||
export my_VENV="${my_VENV#(}"
|
my_VENV="${my_VENV#\(}"
|
||||||
else
|
else
|
||||||
# Best guess
|
# Best guess
|
||||||
export my_VENV="${VIRTUAL_ENV##*/}"
|
export my_VENV="${VIRTUAL_ENV##*/}"
|
||||||
fi
|
fi
|
||||||
prompt="--($my_D, Err ${my_P[*]}, $my_TTY, $my_VENV)---($PWD)--"
|
prompt="--($my_D, Err ${my_P[*]}, $my_TTY, Venv $my_VENV)---($PWD)--"
|
||||||
if [ "${PS1:0:${#my_VENV}+3}" == "($my_VENV) " ]; then
|
# local ps1_prefix
|
||||||
# PS1 will be restored by virtual environment's deactivate script.
|
ps1_prefix="${_OLD_VIRTUAL_PS1%\$\{my_TTY\}*}\${my_TTY}"
|
||||||
# Yeah, that has to be done better, 172 is correct but magic number.
|
ps1_suffix="${_OLD_VIRTUAL_PS1#"$ps1_prefix"}"
|
||||||
export PS1="${_OLD_VIRTUAL_PS1:0:172}, ${my_VENV}${_OLD_VIRTUAL_PS1:172}"
|
# The magic with numbers copies the comma with the colors around it.
|
||||||
fi
|
export PS1="${ps1_prefix}${ps1_prefix:${#ps1_prefix}-39:30}\
|
||||||
|
${ps1_prefix:${#ps1_prefix}-81:14}Venv${ps1_prefix:${#ps1_prefix}-63:14} ${my_VENV}${ps1_suffix}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local fill_size=0
|
local fill_size=0
|
||||||
|
|
@ -114,7 +123,8 @@ function prompt_command() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local OldCmdNo="$CmdNo" # See if we got new command later.
|
local OldCmdNo="$CmdNo" # See if we got new command later.
|
||||||
local Cmd="$(history 1)"
|
local Cmd
|
||||||
|
Cmd="$(history 1)"
|
||||||
CmdNo="${Cmd:0:7}"
|
CmdNo="${Cmd:0:7}"
|
||||||
if [[ -z "$OldCmdNo" ]]; then
|
if [[ -z "$OldCmdNo" ]]; then
|
||||||
Cmd="login"
|
Cmd="login"
|
||||||
|
|
@ -128,18 +138,28 @@ function prompt_command() {
|
||||||
|
|
||||||
function twtty {
|
function twtty {
|
||||||
# The special "\[" and "\]" are telling bash that the text enclosed will not move the caret.
|
# The special "\[" and "\]" are telling bash that the text enclosed will not move the caret.
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local GRAY='\[\033[1;30m\]'
|
local GRAY='\[\033[1;30m\]'
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local LIGHT_GRAY='\[\033[0;37m\]'
|
local LIGHT_GRAY='\[\033[0;37m\]'
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local WHITE='\[\033[1;37m\]'
|
local WHITE='\[\033[1;37m\]'
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local NO_COLOUR='\[\033[0m\]'
|
local NO_COLOUR='\[\033[0m\]'
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local LIGHT_BLUE='\[\033[1;34m\]'
|
local LIGHT_BLUE='\[\033[1;34m\]'
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local YELLOW='\[\033[1;33m\]'
|
local YELLOW='\[\033[1;33m\]'
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local RED='\[\033[0;31m\]'
|
local RED='\[\033[0;31m\]'
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local LIGHT_RED='\[\033[1;31m\]'
|
local LIGHT_RED='\[\033[1;31m\]'
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local GREEN='\[\033[0;32m\]'
|
local GREEN='\[\033[0;32m\]'
|
||||||
|
# shellcheck disable=SC2034
|
||||||
local LIGHT_GREEN='\[\033[1;32m\]'
|
local LIGHT_GREEN='\[\033[1;32m\]'
|
||||||
|
|
||||||
if [ "${UID}" -ne '0' ]; then
|
if [ "${UID}" -ne '0' ]; then
|
||||||
|
|
@ -176,15 +196,19 @@ ${C2})${C3}\$${NO_COLOUR} "
|
||||||
|
|
||||||
export PS2="${C2}─${C1}─${C1}─${NO_COLOUR} \[\033[K\]"
|
export PS2="${C2}─${C1}─${C1}─${NO_COLOUR} \[\033[K\]"
|
||||||
# Set my_P to the exit codes of the last command pipe.
|
# Set my_P to the exit codes of the last command pipe.
|
||||||
|
# shellcheck disable=SC2016
|
||||||
local P='my_P=("${PIPESTATUS[@]}");prompt_command'
|
local P='my_P=("${PIPESTATUS[@]}");prompt_command'
|
||||||
if declare -p PROMPT_COMMAND &>/dev/null; then
|
if declare -p PROMPT_COMMAND &>/dev/null; then
|
||||||
local re='^declare -a '
|
local re='^declare -a '
|
||||||
if [[ "$(declare -p PROMPT_COMMAND)" =~ $re ]]; then # Array, supported since bash 5.1
|
if [[ "$(declare -p PROMPT_COMMAND)" =~ $re ]]; then # Array, supported since bash 5.1
|
||||||
PROMPT_COMMAND=("$P" "${PROMPT_COMMAND[@]}")
|
PROMPT_COMMAND=("$P" "${PROMPT_COMMAND[@]}")
|
||||||
else # String
|
else # String
|
||||||
|
# shellcheck disable=SC2178
|
||||||
|
# shellcheck disable=SC2128
|
||||||
PROMPT_COMMAND="$P;${PROMPT_COMMAND}"
|
PROMPT_COMMAND="$P;${PROMPT_COMMAND}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
# shellcheck disable=SC2178
|
||||||
PROMPT_COMMAND="$P"
|
PROMPT_COMMAND="$P"
|
||||||
fi
|
fi
|
||||||
unset P
|
unset P
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
Summary: Gwebu profile.d - cool date, prompt with history, aliases
|
Summary: Gwebu profile.d - cool date, prompt with history, aliases
|
||||||
Name: gwebu-profile
|
Name: gwebu-profile
|
||||||
Version: 1.0.7
|
Version: 1.0.7
|
||||||
Release: 1
|
Release: 2
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
Source0: profile.d-%{version}-%{release}.tar.xz
|
Source0: profile.d-%{version}-%{release}.tar.xz
|
||||||
|
|
@ -41,6 +41,9 @@ install -m 0644 etc/profile.d/*.sh %{buildroot}%{_sysconfdir}/profile.d/
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Nov 02 2025 Doncho N. Gunchev <dgunchev@gmail.com> - 1.0.7-2
|
||||||
|
- Fixing VENV again...
|
||||||
|
|
||||||
* Tue May 27 2025 Doncho Gunchev <doncho.gunchev@flyr.com> - 1.0.7-1
|
* Tue May 27 2025 Doncho Gunchev <doncho.gunchev@flyr.com> - 1.0.7-1
|
||||||
- Shorten ~/.ssh/controlmasters to ~/.ssh/c (104 char limit on mac).
|
- Shorten ~/.ssh/controlmasters to ~/.ssh/c (104 char limit on mac).
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue