Run following bash script:
#!/bin/bash
# For binaries
SRC_BIN_DIR="/usr/bin"
DEST_BIN_DIR="$HOME/.local/uubin"
# Ensure destination directory exists
mkdir -p "$DEST_BIN_DIR"
# Find files starting with 'uu_' in $SRC_BIN_DIR
find "$SRC_BIN_DIR" -type f -name 'uu_*' | while read -r src_file; do
# Get the base filename
filename=$(basename "$src_file")
# Strip the 'uu_' prefix
stripped_name="${filename#uu_}"
# Copy to destination with new name, preserving attributes
cp -u --preserve=mode,timestamps "$src_file" "$DEST_BIN_DIR/$stripped_name"
# Make sure it's executable
chmod +x "$DEST_BIN_DIR/$stripped_name"
done
echo "All uu_ files copied to $DEST_BIN_DIR with prefix stripped."
# For manual pages
SRC_MAN_DIR="/usr/share/man/man1"
DEST_MAN_DIR="$HOME/.local/share/man/man1"
# Ensure destination directory exists
mkdir -p "$DEST_MAN_DIR"
find "$SRC_MAN_DIR" -type f -name 'uu_*.gz' | while read -r src_file; do
# Get the base filename
filename=$(basename "$src_file")
# Strip the 'uu_' prefix
stripped_name="${filename#uu_}"
# Copy to destination with new name, preserving attributes
ln -sf "$SRC_MAN_DIR/$filename" "$DEST_MAN_DIR/$stripped_name"
done
echo "All uu_ man files linked to $DEST_MAN_DIR with prefix stripped."
then appending the PATH
in your rc profile, if you are using bash, it would be ~/.bashrc
or ~/.bash_profile
:
export PATH="$HOME/.local/uubin:$PATH"
and also override manpages path too:
export MANPATH="$HOME/.local/share/man:"
then reload your shell
for fish shell (which is also written in Rust), it is a bit different but pretty much the same, simply modify ~/.config/fish/config.fish
file:
if status is-interactive
# Commands to run in interactive sessions can go here
set -gx PATH $HOME/.local/uubin $PATH
set -gx MANPATH $HOME/.local/share/man:
end