Giter Club home page Giter Club logo

birch's Introduction

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

birch's People

Contributors

colindean avatar dylanaraps avatar dzove855 avatar fehawen avatar l-warden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

birch's Issues

Unable to connect to irc.talkabout.cf

I used the following to join an irc network:

./birch -s irc.talkabout.cf -u testing -c '#a11y'

It acts like it joined but when I type something, it shows the following:

-- No external channel messages (#a11y)

The /names command shows no one else. The port is the default of 6667 and when I tried adding it with the -P flag nothing changed. It works just fine on freenode though.

How to scroll ?

Hi, first thank you for making this aesthetic irc client. It might be stupid question, but how to scroll to see previous message? I'm using alacritty terminal and sometime using termux app to open birch but i can't scroll to see the previous message.

Again, thank you.

$temp_dir/birch-$pid-$2: No such file or directory

I get the following messages from time to time:

path/to/birch: line 87: /tmp/birch-[pid]-[#nickname-random-text]: No such file or directory

Out of curiosity, I added the following to irc_print():

tee -a $HOME/birch-log.txt >> /dev/null << EOT

time: $(date)
pid: $pid
channel: $chan
channels: ${channels[*]}
temp_dir: $temp_dir
arg1: $1
arg2: $2

EOT

And here's the output I receive, where the second paragraph's arg1 and arg2 seems to be what's causing the No such file or directory error:

time: Tue 04 Feb 2020 03:26:55 PM CET
pid: 17947    
channel: #archlinux
channels: #kisslinux
temp_dir: /tmp
arg1:        <-- ^[[1;36mNekit1234007^[[m has quit ^[[1m#[email protected] QUIT :Ping timeout: 272 seconds^[[m
arg2: #[email protected] QUIT :Ping timeout: 272 seconds

time: Tue 04 Feb 2020 03:27:02 PM CET
pid: 17947
channel: #archlinux
channels: #kisslinux #archlinux
temp_dir: /tmp
arg1:        <-- ^[[1;34msigmundv^[[m has quit ^[[1m#sigmundv!sigmundv@nat/ibm/x-mngnfelapcnukspr QUIT :Ping timeout: 265 seconds^[[m
arg2: #sigmundv!sigmundv@nat/ibm/x-mngnfelapcnukspr QUIT :Ping timeout: 265 seconds

time: Tue 04 Feb 2020 03:27:05 PM CET
pid: 17947
channel: #archlinux
channels: #kisslinux #archlinux
temp_dir: /tmp
arg1:        --> ^[[1;36mNekit1234007^[[m has joined ^[[1m#archlinux^[[m
arg2: #archlinux
                                                                                                        
time: Tue 04 Feb 2020 03:27:19 PM CETpid: 17947
channel: #archlinux
channels: #kisslinux #archlinux
temp_dir: /tmp
arg1:        --> ^[[1;34mTripleDES^[[m has joined ^[[1m#archlinux^[[m
arg2: #archlinux

Not sure if I should edit out any nicknames etc for privacy concerns; let me know and I'll edit it.

Furthermore, not sure if this is due to misuse from my end or if it's something worth looking into.

Inverted current channel tab

Discussion

This might just be personal preference, but I dislike the way of highlighting the current channel by inverting the colors, as it is done currently. This is a pet peeve of mine in general, having such a glaring element.

current way

I've patched my fork to use bold instead. It's less readable but more aesthetic IMO:

2020-03-05_15-39

What does the community think? What about underline?

2020-03-05_15-42

Feature wishlist

  • Command line flag for specifying custom port
  • Multi-channel join at startup
  • Option to specify server username (not to be confused with the nickname)
  • Buffer list
  • Keyboard nav for buffers
  • Respond to VERSION, PING, ACTION Action done. Not going to bother with others.
  • A /me command
  • Nick highlight color
  • Optional notifications
  • Send raw commands (/r CMD perhaps)
  • Nickname tab completion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.