Category Archives: zsh

Install Silversearcher-ag on Ubuntu

The Silversearcher tool is a super fast search tool that gives you rich information when searching for a string through all your files.

To install it:

sudo apt install silversearcher-ag

The Github project page:

https://github.com/ggreer/the_silver_searcher

You can find answers about why it is so fast, a chance to collaborate and other info there.

Cheers!

Advertisements

npm/yarn: live-server installation issue

Executive summary:

ISSUE:

$ live-server
zsh: command not found: live-server SOLUTION: $ export PATH=$PATH:/home/user/.yarn/bin/

DETAILS:

Today my attempt to install the live-server package in a Linux Mint Sylvia (Ubuntu Xenial) box using yarn failed. The installation went just fine, with just some info messages:

$ yarn global add live-server
yarn global v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
warning Pattern ["object-assign@latest"] is trying to unpack in the same destination "/home/dbkreling/.cache/yarn/v1/npm-object-assign-4.1.1-2109adc7965887cfc05cbbd442cac8bfbb360863" as pattern ["object-assign@^4.1.0","object-assign@^4"]. This could result in a non deterministic behavior, skipping.
info fsevents@1.1.3: The platform "linux" is incompatible with this module.
info "fsevents@1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "live-server@1.2.0" with binaries:
- live-server
Done in 1.98s

Cool! And then..

$ live-server
zsh: command not found: live-server

 

Whatta?

Digging it further I found it (no pun intended) hidden in my home directory:

$ sudo find / -name "*live-server*"
[sudo] password for dbkreling:
find: ‘/run/user/1000/gvfs’: Permission denied
/home/dbkreling/.yarn/bin/live-server
/home/dbkreling/.config/yarn/global/node_modules/.bin/live-server
<...snip...>

Looking at my PATH, I had no .yarn directory whatsoever, so this is what I got:

export_yarn_to_path

After adding ~/.yarn/bin to my $PATH I had no more problems  to run it:

$ export PATH =$PATH:$HOME/.yarn/bin

Cheers!

VIM buffer commands

Commands from vim buffers can take long to get into our brains. Practice will lead to perfection… eventually.

Here are some tips to get them into memory faster:

Editor commands:    
  :e filename - Edit a file an existing file in a new buffer
  :sp filename - Open a file in a new buffer and split window
  :vs or :vsp Open a file in a new buffer and split window vertically 
  ctrl+ws - Split window to work in two places of the same file
  ctrl+wv - Split window vertically (and work in the same file)

Navigation commands:
  :bnext (or :bn) - go to next buffer
  :bprev (of :bp) - go to previous buffer
  :bd - delete a buffer (close a file)
  ctrl+ww - switch between windows
  ctrl+wq - Quit a window
    

With pictures to decorate this post:

vim_example1_call

Open up a new file called ‘example1’

vs_example2

With ‘example1’ open, type in ‘:vs example2’ to vertically split the window and edit a new file ‘example2‘. It will open up a new buffer to the left of ‘example1’

sp_example3

From the ‘example2’ buffer, type in ‘:sp example3’ to horizontally split the screen and edit a new file ‘example3‘. It will open a new buffer above ‘example2’

example3_text

All three buffers displayed. Use CTRL-W+W to cycle through them.

Cheers!

Reference: http://www.worldtimzone.com/res/vi.html

Manage users on your system

This is a quick checklist on how to create a user from the command line:
1. useradd -m new_username (add a user called new_username with a home directory)
2. passwd new_username (set a password for new_username)
3. (optional) usermod -aG wheel new_username  (to include the user in the sudoers list)
4. su - new_username (to change to the new_username account)
NOTE: sudo usermod -a -G sudo username (to include user ‘username’ in the sudo group)

EDIT:

5. usermod -s /bin/bash NEW_USERNAME(to set the shell as bash. Change for other shells)

If you need to grant access to you system just for specific applications, you can tweak the visudo file. Using an admin user, issue:

  1. $ sudo visudocmnd_alias
  2. group the commands into aliases (line 18). List all commands you want to grant, separate by comma
  3. grant access to them (line 22). The ‘NOPASSWD’ will restrain to ask for a password for the minicom command. All the other commands ran with sudo will prompt for a password and will fail. To require password, do not include the ‘NOPASSWD’ tag.