Thursday, October 30, 2014

Assigning to a variable from a pipe in Z Shell

Unfortunately or sadly, this could not be done by me for my use case in Bash. I'm looking for a good solution in Bash too. Just to note here. To read from the pipe you just have to use the Read command. It only works this way in Zsh so far.
blkid $dev | sed -n 's/.*UUID=\"\([^\"]*\)\".*/\1/p' | read var;
Now you can easily use that $var in that scope like
echo $var

Z Shell, the fancy in Linux terminal

Z Shell is probably now the best known Shell option for Unix users all over the globe. That too contributed by the fact that most people take the Terminal they get as full and final and never give a second thought about it's improvement. But geeks can't resist exploring and the first option they get astounds them because Z Shell, if compared to Bash, is simple a super set of it's functionality. It gives us a great Terminal which is intelligent and customizable to the point where people might ask you "Which terminal is this?".

Installation: This is fairly simple. Just a quick apt-get
sudo apt-get install zsh
Configuration: After you have installed Z Shell, the very first thing you have to do launch is type in your terminal
zsh
The first you do this, you will get some configuration manual that is navigated using numbers. The procedures are very self explanatory. It helps you configure various Options such as
  • How far back in time do you want to remember commands
  • If you want the shell to search history using partially entered commands (It's neat and powerful)
  • Should all of your terminals be in sync while running
The whole configuration is saved into the file at '/home//.zshrc'.
After you have configured the shell, you can make it your default shell using the command
chsh  -s /bin/zsh

Configuration repositories: Some great configurations for Zsh have come up with full modular support and themes that will make your experience with Z a breeze. These are the most popular to repositories. There are some others that maintain Z shell configurations around the net.
Using these pre-built configurations is very easy. Such as, configuring with Prezto. You need to type in the following after launching Z Shell. The commands will create Z Shell configurations in your home directory.
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
  ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
This will simple clone the repository into your home folder and then, link the configurations in place of your current configurations.


Sunday, October 26, 2014

NodeJS permission issues troubleshooting path

It was such a terrifying experience to have node and especially yeoman not work because of weird permission issues. I fixed the issues finally and kind of think there's pattern to it. This is not a full and final cookbook type of thingy but you might wanna check this method out in case you are stuck with the same issues. First of all
1. If the problem is not in your project directory then it must me in your ~/.config and ~/.npm directories. As you may have seen many newbies of node opt to the sudo method of installing things. But this causes problem regarding permission when yeoman comes in as some of the commands need access to areas where root is not permitted and if you do not use sudo before yo, you get errors about some of the errors where you need root. This mess up is simply caused by sometimes using sudo and sometimes not. Which you have to do because you do not own the ~/.npm directory. Just own it using
sudo chown -R `whoami` ~/.npm
2. If the problem still persists, check your project directories node_modules directory if it has any subdirectory or file deep inside where access is needed it has root privileges required. So you can use the same owning method there too
sudo chown -R `whoami` ~/.npm
3. Always try to install non globally. This will save you a lot of trouble.

Credits: Stackoverflow [ http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo ]

Saturday, October 25, 2014

When 'chsh' simple does not work

I got into this problem lately in a Live environment of the new Ubuntu MATE release where no matter how many times I change the password using 'sudo passwd' it simply does not effect 'chsh'. So, when I type in
chsh -s /usr/bin/zsh
It asks for the password. And when I type the password in, it does not work. It simply says "PAM: Authentication Failure". Ok, so go for Googling. Later, I found out that all user 'home' and 'shell' infos are stored in a file located by '/etc/passwd'. Now you need root to do this. So how do you get root? For a Live system, that's simple. just type in
sudo -i
It should give you the '#' prompt so you're root now. Now just open the file using your favorite editor like
nano /etc/passwd
Then find your user name and change the string right after the last ':' on that line. Done. Reboot and go. For now, I seriously don't know why 'chsh' didn't work. :( anybody have any clues?

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...