Showing posts with label terminal. Show all posts
Showing posts with label terminal. Show all posts

Monday, May 18, 2015

Tweak Terminal Appearance in XFCE4 Ubuntu

I have spent some time recently to fine-tune the looks of my Ubuntu machine in XFCE4. I have slightly modified my conky, created a customized desktop background, started tweaking things under the hood and I have also given some time and thought to the terminal.

The terminal with full black background looks like my computer came from the 90's, so I wanted to give it a fresher, more modern look. I wanted to do the following:
  • Add a transparent background that shows the contents behind the window. This is useful if e.g. I am searching for something on the web and have to issue some commands at the same time. I can see through the window and work faster.
  • Give the window some lighter colours
  • Remove window frame
It is pretty easy to set up these things, everything can be done from within the menus in the terminal. Simply go to  Edit/Preferences and set it the way you want it to look.

Window Management Tweaks

A little trouble came when setting up the transparent background. Namely, it wouldn't show the contents directly behind the window, but rather a greyed out section of the desktop background. This became annoying almost immediately.

The solution was to go to Settings/Settings Manager/Window Management Tweaks/
Settings menu in Xfce4 - Look at Window Manager Tweaks
And tick the checkbox for Enable display compositing.
Window Manager Tweaks menu - check the first tickbox on the top left
After this the terminal window should be transparent, as much as set in the terminal settings menu. Also, if you want to make it look even cooler, you can set it to be more transparent while moving! This applies to all windows on your machine and it not only looks nice, but allows you to roughly see what you will cover with the window. It is actually useful.

Terminal Settings

You wouldn't believe who much cooler it looks like if you take out this option. And don't worry about the closing/minimizing of the window, you can get used to it pretty easily.
  • Close: Ctrl + Shift + Q
  • Maximize: F11

Remove Borders

To disable border on new terminal windows go to Terminal/Edit/Preferences/Appearance
Adjusting temrinal appearance
And uncheck the Display borders around new windows.

Make the Terminal Transparent

This is where you can change the actual transparency of the terminal only. From the "appearance" tab (see above) select Transparent Background in the Background options and adjust the slider to your liking. I am using 80% as this allows me to clearly see the text in the terminal window as well as roughly see the contents behind the window.

This is especially useful when I have to look up references on the internet and copy commands form the browser. I can simply go full screen with the terminal and still see the commands in my browser that I have to type. It also gives a smoother look to the whole thing and doesn't feel so monotone.

Close the terminal and restart it. VoilĂ ! Let me know what you think and if you have some cool customizations on your UI please share it!

Saturday, November 1, 2014

Count the Occurence of All Words in a Number of Text Files

Recently I was given the task to analyse a range of files (around 300) and count the occurrence of all the words in each file. So the aim was to put together a piece of code that goes through all files in a directory, reads in a file, lists all the words occurring in it and counting how many time each word has occurred.

I quickly found out that in case of a single file the process is rather simple, the following code does a fine job,

for w in `cat FILE.txt`; do echo $w;done|sort|uniq -c >> results.out
This code reads in FILE.txt and for each word in it counts its occurrence and the creates a list from it.

However putting this into a recursive script was a little more complicated. So I took another direction and found a piece of code using sed to do the same job on a single file. With this and some scripting knowledge I was able to put together just what I needed.

Additionally, I used the command basename to output the name of the file so I know which file was which.

The final piece of code looks like this,

for file in `ls /PATH/TO/DIRECTORY/`
do
basename /PATH/TO/DIRECTORY/FILE >>
results.out        sed s/' '/\\n/g /PATH/TO/DIRECTORY/FILE | sort | uniq -c | sort -nr >>  results.out
echo "" >>  results.out
done

This does a perfect job and creates a single file with the output containing,
  • File name of each file
  • Occurrence of each word in the file, sorted from high to low
  • Empty line to separate data from each other
If anyone has any other suggestion or comment I am happy to hear it!