NerdFonts in terminal windows


bigrob8181

Recommended Posts

I was able to get this to work yesterday with quite a bit of tinkering and figuring things out.

 

NOTE: YOU WILL BE MESSING WITH INTERNAL UNRAID FILES. IF YOU BREAK THINGS I AM NOT RESPONSIBLE!!! FOLLOW THIS AT YOUR OWN RISK!!

 

These are the nuts and bolts to it:

My /boot/config/go file now includes the following to make this all work:

# Fonts #
    
# Replace the ttyd binary and chmod
mv /usr/bin/ttyd /usr/bin/ttyd_orig
cp /boot/config/custom/ttyd/ttyd /usr/bin/
chmod a+x /usr/bin/ttyd
    
# Symbolic link the libs
ln -s /boot/config/custom/ttyd/libs/libjson-c.so.4 /usr/lib64/libjson-c.so.4
ln -s /boot/config/custom/ttyd/libs/libev.so.4 /usr/lib64/libev.so.4
    
# Create custom terminal command
mv /usr/local/emhttp/plugins/dynamix/include/OpenTerminal.php /usr/local/emhttp/plugins/dynamix/include/OpenTerminal.php.orig
cp /boot/config/custom/ttyd/OpenTerminal.php /usr/local/emhttp/plugins/dynamix/include/
chmod a+r /usr/local/emhttp/plugins/dynamix/include/OpenTerminal.php

 

First clue was using this issue/commit for ttyd.

 

On a separate machine I did the following:

  • Clone the repo for ttyd.
  • I followed this (Build from source (debian/ubuntu)) to build my own ttyd binary with the changes from the commit. I had to manually add the changes.
  • I followed this to build the custom inline.html using the comments from the previous commit. Ex:
    Quote

    export INLINE_FONT=/path/to/ttyd/html/src/style/my font.ttf

     This has to happen before you run the yarn run start or yarn run build commands in each terminal window. note: every time you run yarn run start it will wipe the dist dir that you build with yarn run build.
  • I moved the dist folder (renamed to index) and custom built ttyd binary to the unraid box under /boot/config/custom/ttyd/. I figured this would be a good place for it as it survives reboots. Just make sure its under /boot/config and the go file accurately reflects the path.

 

After getting the files in place, I chmod a+x the binary and ran

Quote

ldd /path/to/my/custom/ttyd

to see what libraries were missing, since it wouldn't run. I was missing libev.so.4 and libjson-c.so.4. I copied these files from my build machine to a libs folder under /boot/config/custom/ttyd/. Now I could run the binary fine.

 

Last step was to implement the new binary with the custom arguments in unraid. I found the call to the binary was in /usr/local/emhttp/plugins/dynamix/include/OpenTerminal.php I copied this file into the /boot/config/custom/ttyd/ folder. I changed line 54 to

if ($retval != 0) exec("ttyd-exec --index=/boot/config/custom/ttyd/index/inline.html --client-option fontFamily='Fira Code Retina Nerd Font Complete' -i '$sock' bash --login");

note: the font family name instead of the file name or path. I had to play with this to get the correct naming scheme. Probably could have run fc-list to see it on the build machine. This name just so happens to be the font I used.

 

After figuring everything out I made copies of the original files and moved my new ones into place and symlinked the libraries. code listed in the go file above.

 

I have yet to reboot the machine to verify it survives a reboot. I think it should, I will update the post if I find it does not to correct any problems.

 

To get my terminal layout this is added to a .bash_profile and copied on boot (from the go file) to /root/.

OS_ICON=   # Replace this with your OS icon
PS1="\n \[\033[0;34m\]╭─────\[\033[0;31m\]\[\033[0;37m\]\[\033[41m\] $OS_ICON \u@\h \[\033[0m\]\[\033[0;31m\]\[\033[0;34m\]─────\[\033[0;32m\]\[\033[0;30m\]\[\033[42m\] \w \[\033[0m\]\[\033[0;32m\] \n \[\033[0;34m\]╰ \[\033[1;36m\]\$ \[\033[0m\]"

 

To restore back to unraid's defaults after applying these changes do the following:

# Restore the ttyd binary to original
rm /usr/bin/ttyd
mv /usr/bin/ttyd_orig /usr/bin/ttyd
    
# Remove symbolic links
rm /usr/lib64/libjson-c.so.4
rm /usr/lib64/libev.so.4
    
# Restore the original Terminal command
rm /usr/local/emhttp/plugins/dynamix/include/OpenTerminal.php
mv /usr/local/emhttp/plugins/dynamix/include/OpenTerminal.php.orig /usr/local/emhttp/plugins/dynamix/include/OpenTerminal.php

Remove added code from go file

terminal_nerdfonts.png

Link to comment

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.   Restore formatting

  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.