Skip to content

Instantly share code, notes, and snippets.

View AnonymouX47's full-sized avatar
💭
Solving Problems...

AnonymouX47 AnonymouX47

💭
Solving Problems...
View GitHub Profile
@dylon
dylon / .bash_profile
Last active November 18, 2024 23:43
How to get 256 colors in a standard Linux terminal + screen (without X windows).
# ...
# This is for what I would consider a standard setup, where TTY's 1 -- 6 are
# "linux" terminals and TTY's 7+ are reserved for X windows. You should adjust
# it to your setup, accordingly.
#
# ::: Important ::: You must have both fbterm and screen installed and on your
# path for this to work.
virtual_terminal="$( tty | grep -oE ....$ )"
@XVilka
XVilka / TrueColour.md
Last active December 20, 2024 19:12
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@adeekshith
adeekshith / .git-commit-template.txt
Last active October 20, 2024 21:10 — forked from Linell/.git-commit-template.txt
This commit message template helps you write great commit messages and enforce it across teams.
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
@jdloft
jdloft / .bash_profile
Last active October 18, 2021 01:36 — forked from dylon/.bash_profile
How to get 256 colors in a standard Linux terminal + screen (without X windows).
# ...
# This is for what I would consider a standard setup, where TTY's 1 -- 6 are
# "linux" terminals and TTY's 7+ are reserved for X windows. You should adjust
# it to your setup, accordingly.
#
# ::: Important ::: You must have both fbterm and screen installed and on your
# path for this to work.
case $(tty) in /dev/tty[0-6]*)
@egmontkob
egmontkob / Hyperlinks_in_Terminal_Emulators.md
Last active December 16, 2024 17:51
Hyperlinks in Terminal Emulators
@victor-iyi
victor-iyi / .vimrc
Last active May 19, 2021 11:09
My Vim configuration file
" File: ~/.vimrc
"
" Author: Victor I. Afolabi
syntax enable
colorscheme desert
" highlight Normal guibg=none
" =============================================================================
@christianparpart
christianparpart / terminal-synchronized-output.md
Last active December 13, 2024 12:43
Terminal Spec: Synchronized Output

Synchronized Output

Synchronized output is merely implementing the feature as inspired by iTerm2 synchronized output, except that it's not using the rare DCS but rather the well known SM ? and RM ?. iTerm2 has now also adopted to use the new syntax instead of using DCS.

Semantics

When rendering the screen of the terminal, the Emulator usually iterates through each visible grid cell and renders its current state. With applications updating the screen a at higher frequency this can cause tearing.

This mode attempts to mitigate that.

@AlexWaygood
AlexWaygood / last_n_lines.py
Last active March 10, 2024 16:30
Script to find the last `n` lines of a file
import os
from collections import deque
from collections.abc import Iterator, Sequence
from typing import Final, Protocol
class SeekableBytesFile(Protocol):
def seek(self, position: int, whence: int = ..., /) -> int: ...
def read(self, amount: int, /) -> bytes: ...
@willmcgugan
willmcgugan / last_lines.py
Created March 2, 2024 16:10
Get the last lines from a file
import mmap
def get_last_lines(path: str, count: int) -> list[str]:
"""Get count last lines from a file."""
with open(path, "r+b") as text_file:
text_mmap = mmap.mmap(text_file.fileno(), 0, mmap.ACCESS_READ)
position = len(text_mmap)
while count and (position := text_mmap.rfind(b"\n", 0, position)) != -1:
count -= 1

Private Mode for In-Band Window Resize Notifications

Terminal emulators typically receive window resize events by installing a signal handler for the SIGWINCH signal. Handling of these signals can create challenges due to their inherently racy properties. Resize events must be synchronized with other application state in a safe manner.

Standard control sequences exist to query the current terminal size from the terminal and receive an in-band control sequence with the window size. However, this system requires polling - which is not ideal. Usually, SIGWINCH handling