Jump to content

bash немного красок.


Recommended Posts

ставим opkg install bash, далее создаём два файла touch /opt/etc/bash.bashrc и touch /opt/root/.bashrc с содержимым для bash.bashrc,

Скрытый текст
# File: /opt/etc/bash.bashrc

# System-wide .bashrc file for interactive bash shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /opt/etc/profile.

  # set variable identifying the chroot you work in (used in the prompt below)
	if [ -z "$chroot" ] && [ -r /opt/etc/chroot ]; then
			chroot=$(cat /opt/etc/chroot)
	fi

# set a fancy prompt (non-color, overwrite the one in /opt/etc/profile)
	PS1='${chroot:+($chroot)}\w \$ '

	alias mc="mc -c"

 

а в .bashrc вставим

Скрытый текст
# File: ~/.bashrc
#
# ~/.bashrc: executed by bash for non-login shells.

  # for setting history length see HISTSIZE and HISTFILESIZE in bash
	HISTSIZE=500
	HISTFILESIZE=500

  # enable color support of ls and also add handy aliases
	if [ -x /opt/bin/dircolors ]; then
			test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
			alias ls='ls --color=auto'
			#alias dir='dir --color=auto'
			#alias vdir='vdir --color=auto'

			alias grep='grep --color=auto'
			alias fgrep='fgrep --color=auto'
			alias egrep='egrep --color=auto'
	fi

  # some more ls aliases
	alias ll='ls -alF'
	alias la='ls -A'
	alias l='ls -CF'

  # Alias definitions.
  # You may want to put all your additions into a separate file like
  # ~/.bash_aliases, instead of adding them here directly.

	if [ -f ~/.bash_aliases ]; then
			. ~/.bash_aliases
	fi

 

при желании можно сделать третий файл touch /opt/root/.bash_aliases для своих aliases или писать в /opt/root/.bashrc

вот и всё.

Скрытый текст

2023-06-10_05-29-47.thumb.jpg.ec6f6bb4af863bbfb9fffa2c840b5164.jpg

 

Edited by Meccep45
конф инфа была лишней
  • Thanks 1
  • Upvote 1
Link to comment
Share on other sites

  • 9 months later...

из телеги https://t.me/entware

screen_2024-03-21_18:42:00-ssh.png

Скрытый текст
#!/bin/sh

. /opt/etc/profile

# PROMPT
# colors

blk="\033[1;30m"   # Black
red="\033[1;31m"   # Red
grn="\033[1;32m"   # Green
ylw="\033[1;33m"   # Yellow
blu="\033[1;34m"   # Blue
pur="\033[1;35m"   # Purple
cyn="\033[1;36m"   # Cyan
wht="\033[1;37m"   # White
clr="\033[0m"      # Reset

# Set the prompt.

sh_prompt() {
    PS1=${cyn}' \w '${grn}' \$ '${clr}
}

sh_prompt

### opkg update
opkg update > /dev/null 2>&1

### deps: coreutils-df procps-ng-free procps-ng-uptime

### processor type
_CPU_TYPE="$(cat /proc/cpuinfo | awk -F: '/(model|system)/{print $2}' | head -1 | sed 's, ,,')"

if [ "$(uname -m)" = "aarch64" ]; then
    CPU_TYPE="$_CPU_TYPE"
else
    CPU_TYPE="$_CPU_TYPE$(cat /proc/cpuinfo | awk -F: '/cpu model/{print $2}' | head -1)"
fi

printf "\n"
printf "   ${wht} %-10s ${ylw} %-30s ${wht} %-10s ${ylw}    %-30s ${clr}\n" \
    "Date:" "📆$(date)" \
    "Uptime:" "🕐 $(uptime -p)"
printf "   ${wht} %-10s ${blu} %-30s ${wht} %-10s ${blu}  %-30s ${clr}\n" \
    "Hostname:" "$(hostname -f)" \
    "Accessed IP:" "$(hostname -i)"
printf "   ${wht} %-10s ${grn} %-30s ${wht}   %-10s ${grn}    %-30s ${clr}\n" \
    "OS:" "$(uname -s) 🐧" \
    "CPU:" "$CPU_TYPE"
printf "   ${wht} %-10s ${grn} %-30s ${wht} %-10s ${grn} %-30s ${clr}\n" \
    "Kernel:" "$(uname -r)" \
    "Architecture:" "$(uname -m)"
printf "   ${wht} %-10s ${pur} %-30s ${clr}\n" \
    "Disk:" "$(df -h | grep '/opt' | awk '{print $2" (size) / "$3" (used) / "$4" (free) / "$5" (used %) : 💾 "$6}')"
printf "   ${wht} %-10s ${pur} %-30s ${clr}\n" \
    "Memory:" "$(free -h --mega | awk '/Mem/{print $2" (всего) / "$3" (использовано) / "$4" (свободно)"}')"
printf "   ${wht} %-10s ${pur} %-30s ${ctl}\n" \
    "Swap:" "$(free -h --mega | awk '/Swap/{print $2" (total) / "$3" (used) / "$4" (free)"}')"
printf "   ${wht} %-10s ${pur} %-30s ${clr}\n" \
    "LA:" "$(cat /proc/loadavg | awk '{print $1" (1m) / "$2" (5m) / "$3" (15m)"}')"
printf "   ${wht} %-10s ${red} %-30s ${wht}\n" \
    "User:" "🤵 $(echo $USER)"
if [ -f "/opt/etc/entware_release" ]; then
    printf "   ${wht} %-10s ${grn} %-30s ${crl}\n" \
        "Dist:" "$(grep ^PRETTY /opt/etc/entware_release | cut -d'"' -f2)"
else
    printf "   ${wht} %-10s ${grn} %-30s ${crl}\n" \
        "Dist:" "Entware"
fi
printf "   ${wht} %-10s ${cyn} %-30s ${wht}     %-10s ${cyn} %-30s ${clr}\n" \
    "Installed:" "📦📦 $(opkg list-installed | wc -l)" \
    "Upgrade:" "📦 $(opkg list-upgradable | wc -l)"
printf "\n"

 

установить пакеты: `opkg install coreutils-df procps-ng-free procps-ng-uptime`

править по вкусу (удалить, добавить, изменить вывод)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...