Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

`ifconfig-color` is a shell script that enhances the readability of `ifconfig` output by applying color to various elements. This makes it easier to interpret network interface details, packet counts, MAC addresses, and more.

License

NotificationsYou must be signed in to change notification settings

AzizEmir/ifconfig-color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

ifconfig-color is a python code that enhances the readability ofifconfig output by applying color to various elements. This makes it easier to interpret network interface details, packet counts, MAC addresses, and more.

image

importreimportsubprocess# ifconfig çıktısını alifconfig_output=subprocess.check_output(['ifconfig'],text=True)# Regex desenleri ve renk kodlarını tutan bir sözlükpatterns_and_colors= {# 'prefixlen' değerini tespit et ve magenta (pembe) renkte vurgular'(?<=prefixlen\s)\d+':"\033[38;2;255;0;255m",# magenta #FF00FF rgb(255,0,255)# 'scopeid' değerini tespit et ve magenta (pembe) renkte vurgular'(?<=scopeid\s0x)[a-fA-F0-9]+':"\033[38;2;255;0;255m",# magenta #FF00FF rgb(255,0,255)# 'KiB' veya 'MiB' ile biten sayıları tespit et ve magenta (pembe) renkte vurgular'\(\d+(\.\d+)?\s(KiB|MiB|GiB|B)\)':"\033[38;2;255;0;255m",# magenta #FF00FF rgb(255,0,255)# Ağ yapılandırma ile ilgili anahtar kelimeleri (inet6, ether, prefixlen, vb.) sarı renkte vurgular'\b(inet6|inet|netmask|broadcast|ether|prefixlen|scopeid|RX packets|TX packets)\b':"\033[38;2;255;200;0m",# yellow #FF8C00 rgb(255,140,0)# IPv4 adreslerini tespit et ve magenta (pembe) renkte vurgular'(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}':"\033[38;2;255;0;255m",# magenta #FF00FF rgb(255,0,255)# Arayüz isimlerini (örneğin 'eth0', 'wlan0') tespit et ve mavi renkte vurgular'^([\w-]+):':"\033[38;2;30;144;255m",# rgb(30, 144, 255) mavi# MAC adreslerini tespit et ve yeşil renkte vurgular'(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}':"\033[38;2;0;255;144m",# rgb(0, 255, 144) yeşil# ipv6r'(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])) ':"\033[38;2;255;0;255m",# mediumpurple #9370DB rgb(147,112,219)}# Her bir regex deseni ve renk kodu için işlemleri uygulahighlighted_output=ifconfig_outputforpattern,color_codeinpatterns_and_colors.items():# Eşleşen kısımları renklendirmek için regex'i uygulahighlighted_output=re.sub(pattern,lambdamatch:f"{color_code}{match.group(0)}\033[0m",highlighted_output,flags=re.M)# Renklendirilmiş çıktıyı terminale yazdırprint(highlighted_output)

About

`ifconfig-color` is a shell script that enhances the readability of `ifconfig` output by applying color to various elements. This makes it easier to interpret network interface details, packet counts, MAC addresses, and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp