• This repository has been archived on 26/Apr/2024
  • Stars
    star
    312
  • Rank 129,542 (Top 3 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An IRC client written in bash

m birch

An IRC client written in bash.

scrot

Features

* Full power of readline for input and keybindings. 

  This is thanks to bash's `read -e`. Birch will read a readline
  based configuration file from the environment variable 
  '$BIRCH_INPUTRC' which allows you to customize everything.

* Tab completion of nicks and channels. 
  
  Bash hardcodes `read -e` tab completion to the file based one. This 
  works fine for channel completion as each channel log is stored in 
  a file anyway. For nick completion, birch will create an empty file 
  for each nick in the channel. Hey, it works.

* Unique (or semi-unique) nick colors.

  All nicks are colored based on their length. The length is mapped
  to a color between 1 and 6 which is then used as input for 
  '\033[1;3<mapped_col>m'.

Caveats (or limitations)

* Nick column is fixed and truncated to 10 columns wide.
  
  This is something fixable down the line. It merely serves to
  simplify the alignment of messages into two columns (nick and
  messages).

* Lines are word-wrapped to a fixed 60 columns.

  This is also fixable down the line though a lot more painful
  than the nick column issue. POSIX fold is used to achieve the
  word wrapping but doesn't take into account non-printable
  characters and unicode.

  What this means is that wrapping will always be a little _off_
  as escape sequences, IRC formatting and unicode will throw
  out all attempts at calculating the "visible" line length.

  It's an interesting problem to solve. I've made a myriad of
  attempts at writing a suitable function in bash though they're
  all too slow (as expected!).

* No automatic server reconnect.

  This should be fairly easy to fix though I need to figure out
  the best way of doing so.

* No SSL (sadly).

  The network connection is through bash's builtin /dev/tcp
  feature which doesn't allow for SSL.

Interesting facts

* Connection to the IRC server happens without external
  utilities.

  Bash support network connections via two virtual device
  directories it "creates" in '/dev/'. 

  '/dev/tcp/host/port' and '/dev/udp/host/port'.

  I don't exactly know _why_ these were implemented as
  it's a crazy feature for a shell to have. I haven't seen
  them widely used either.

* The input loop and listener loop can't communicate.

  Birch utilizes two loops to work. One for the input and 
  an additional loop to listen to incoming IRC messages.

  When something is run asynchronously in bash with '&', it
  runs in a subshell (a second bash process).

  What this means is that the async code can't communicate
  with the blocking code. Any variables set in the input loop
  once both loops are running won't be visible in the async
  listener loop to give an example.

  To work around this birch utilizes files for IPC between the
  two. The current channel is communicated by maintaining a 
  symlink and checking its target where needed.

  Example: .c -> '#current_channel'

* This was HARD.

  Trying to make the input prompt and async listener (which
  spits out messages to the terminal) play nice took a lot
  of work.

  As birch implements a TUI _manually_ we're dealing with bare
  escape sequences to tie everything together.

  When a message needs to be printed, the cursor must move from
  the input prompt to the output area, print the message and
  finally return back to the input prompt.

  All of this must happen just right to ensure that this series
  of cursor movements doesn't end up mangling the display of 
  the interface.

  Birch has gone through a lot of rewrites to get this perfect.
  Fun fact: The older revisions read input char by char and
  implemented a lot of readline by hand.

Usage

birch <args>

-s <host>
-c <channel>
-u <nick>
-p <server_password>
-U <server_username>
-P <port>
-x <cmd>

-h (help)
-v (version)

Dependencies

  • bash 4+
  • POSIX compatible fold, rm

Keybindings

Ctrl+n - Next buffer.
Ctrl+p - Previous buffer.
Tab    - Completion of nicks and channels.

Further, all readline keybindings are available for use. See the
readline or bash manpages for a list of these. 

Keybindings to birch may also be set via a .inputrc file. Which
can be configured by setting `$BIRCH_INPUTRC`.

(BIRCH_INPUTRC=/path/to/birch-inputrc birch)

Commands

Channels:

/join <channel>       - Join a channel.
/part <channel>       - Leave a channel.
/quit                 - Quit out of birch.

Messages: 

/msg <nick> <message> - Message a user.
/me  <message>        - Send an action.

Navigation:

/next                 - Next buffer.
/prev                 - Previous buffer.
/<num>                - Buffer by number (0 indexed).

Other:

/nick <nick>          - Change nickname.
/names                - Display all nicks in channel.
/topic                - Display channel topic.
/away <message>       - Set afk message.
/raw <args>           - Send a raw IRC message.

Customization

(These are environment variables.)

# Set the formatting of the tab line's selected item.
# This defaults to reverse video.
BIRCH_STATUS='\e[7m'

# The path to a readline based .inputrc file to change
# birch's input settings. 
#
# See http://man7.org/linux/man-pages/man3/readline.3.html
BIRCH_INPUTRC=/path/to/file

More Repositories

1

pure-bash-bible

πŸ“– A collection of pure bash alternatives to external processes.
Shell
35,948
star
2

neofetch

πŸ–ΌοΈ A command-line system information tool written in bash 3.2+
Shell
20,984
star
3

pywal

🎨 Generate and change color-schemes on the fly.
Python
8,114
star
4

pure-sh-bible

πŸ“– A collection of pure POSIX sh alternatives to external processes.
Shell
6,293
star
5

fff

πŸ“ A simple file manager written in bash.
Shell
4,028
star
6

pfetch

🐧 A pretty system information tool written in POSIX sh.
Shell
2,018
star
7

sowm

An itsy bitsy floating window manager (220~ sloc!).
C
894
star
8

wal

🎨 Generate and change colorschemes on the fly. Deprecated, use pywal instead. -->
Shell
724
star
9

pxltrm

πŸ–ŒοΈ pxltrm - [WIP] A pixel art editor inside the terminal
Shell
642
star
10

dotfiles

πŸ™ dotfiles
Vim Script
541
star
11

writing-a-tui-in-bash

How to write a TUI in BASH
499
star
12

pash

πŸ”’ A simple password manager using GPG written in POSIX sh.
Shell
336
star
13

torque

πŸš‚ A TUI client for transmission written in pure bash.
Shell
222
star
14

shfm

file manager written in posix shell
Shell
215
star
15

wal.vim

🎨 A vim colorscheme for use with wal
Vim Script
214
star
16

promptless

πŸš€ A super fast and extremely minimal shell prompt.
Shell
186
star
17

paleta

Change terminal colors on-the-fly independent of terminal emulator.
C
182
star
18

bin

πŸ—‘οΈ scripts
Shell
145
star
19

bum

🎡 Download and display album art for mpd/mopidy tracks.
Python
134
star
20

openbox-patched

PKGBUILD and patches for Openbox with Rounded Corners
111
star
21

fff.vim

A plugin for vim/neovim which allows you to use fff as a file opener.
Vim Script
103
star
22

bareutils

A coreutils written in pure bash.
Shell
88
star
23

k

kiss pkg man written in c
C
55
star
24

clutter-home

clutter your home directory!
50
star
25

eiwd

iwd without dbus
C
46
star
26

barsh

Use your terminal as a bar
Shell
38
star
27

nosj

a json parser written in pure bash
Shell
36
star
28

bush

This is an experiment to see how many standard tools and functions we can re-implement in pure bash.
Shell
33
star
29

crayon

🎨 A dark 16 color colorscheme for Vim, Gvim, and Nvim
Vim Script
29
star
30

startpage

πŸ”— Simple start page written in HTML/SCSS
CSS
29
star
31

ryuuko

🎨 A colorscheme~
Vim Script
28
star
32

wiki

KISS Linux - Wiki (The wiki is now a part of the website)
27
star
33

hello-world.rs

πŸš€Memory safe, blazing fast, configurable, minimal hello world written in rust(πŸš€) under 1 line of code with few(774πŸš€) dependenciesπŸš€
Rust
25
star
34

pow

Shell
24
star
35

root.vim

🌴 Automatically set directory to your project's root based on a known dir/file.
Vim Script
22
star
36

nfu

Neofetch Utils - A set of C programs to print system information.
C
22
star
37

wm

xcb wm
C
20
star
38

pkg

Package Manager for Kiss Linux
Shell
18
star
39

dylanaraps

17
star
40

okpal

okpal - Swap on the fly between a bunch of palettes
Shell
15
star
41

neofetch-branding

Logos for Neofetch
15
star
42

codegolf

my bash code golfs
15
star
43

eiwd_old

SEE: https://github.com/dylanaraps/eiwd
C
14
star
44

taskrunner.nvim

πŸƒ Runs Gulp/Gruntfiles in terminal splits
Vim Script
14
star
45

discord-selena

Log all Discord messages for transparency
Python
12
star
46

libdbus-stub

stub libdbus to appease
C
12
star
47

str

C
11
star
48

dylan-kiss

Dylan's KISS repository
Objective-C
11
star
49

kiss-flatpak

flatpak for kiss
Shell
11
star
50

blog

Shell
10
star
51

kiss-initramfs

[WIP] initramfs tool for KISS (help wanted!)
Shell
9
star
52

sowm-patches

READ: https://github.com/dylanaraps/sowm/pull/57
8
star
53

golfetch

simple fetch script for Linux.
Shell
8
star
54

reddit-sidebar-toggle

πŸ‘½ Toggle the sidebar on reddit.com
JavaScript
8
star
55

coal

πŸš‚ A bash script that takes a list of colors and outputs them in various formats for use in other programs.
Shell
8
star
56

dylan.k1ss.org

HTML
7
star
57

wayland-experiment

Shell
6
star
58

uncompress

6
star
59

xyz-redirect

simply a cheeky way to 301 redirect https to another domain leveraging netlify to handle the SSL cert.
HTML
5
star
60

repo

πŸ“¦ Dylan's Cydia Repo
Shell
5
star
61

dlink-ssid-bypass

πŸ“‘ Bypass SSID validation on D-Link DSL-2750B
4
star
62

languages

Shell
4
star
63

pywal-branding

Logos for pywal
Shell
4
star
64

blag

blag
HTML
3
star
65

oldyiayias

Old website for Yiayias Greek Cafe
CSS
3
star
66

kisslinux-irc-logs

Freenode #kisslinux IRC logs (2019-2021)
3
star
67

pascal_lint.nvim

πŸ† Show fpc compiler output in a neovim split.
Vim Script
3
star
68

dylanaraps.github.io-old

πŸ”— My personal website.
HTML
2
star
69

2211

mnml trmnl using vte
C
2
star
70

kiss-submodule-links

Shell
2
star
71

eww-static-test

Rust
1
star
72

yiayias

Recreating Yiayia's website 6 months later
HyPhy
1
star
73

google

Remake of Google.com for an assignment
HTML
1
star