Showing posts with label fedora. Show all posts
Showing posts with label fedora. Show all posts

Thursday, March 3, 2016

Copying with tmux and vim on Fedora 23

I use tmux and vim on Fedora 23. When I have vertically split windows, selecting with my mouse cursor selects across multiple open files. Today I finally got unlazy and googled around enough to figure out how to get text into my system's clipboard (since vim uses it's own paste buffer) from vim.

I used
Conner's answer here: http://stackoverflow.com/questions/11489428/how-to-make-vim-paste-from-and-copy-to-systems-clipboard and Ignacio Vazquez-Abrams's answer here:
http://superuser.com/questions/194747/how-to-install-vim-with-clipboard-support-on-fedora
to get copy/paste working for me.
  1. install gvim
  2. create an alias in my .bashrc file so I don't have to type 'gvim -v' instead of 'vi'
  3. To select:
    1. position your cursor at the beginning of the text block you want to copy
    2. shift+v ('V')
    3. arrow down
    4. "yank" the text using "+y (keydown shift ' and +, then keyup shift, then y)
    5. Paste into a different program (like gedit, which I use as a scratch-pad) using your mouse wheel or ctrl+v
Pasting is easy.

If you're new to vim, use :paste before pasting in code-blocks to preserve formatting.


Thursday, January 21, 2016

My Vagrant How-To (with libvirt)

I am super late the the Vagrant party. "All you have to do is vagrant up!" is all I hear from developers everywhere. But when I tried it, that was not my experience.

A lot of my life over the past several years has revolved around Linux and libvirt. I even did some backend work for a virtualization management platform called Kimchi. But since I was coming from the land of, "Here's your image, and here's your VM," I over-complicated it. "Where is the image I just downloaded?" "Doesn't my Vagrantfile need to be in the same place as that image?" The answers: "Don't worry about it," and "No."

So here's what I think is a pretty good explanation for people who are used to something like virt-manager but want to use Vagrant.

Intro: Projects, Vagrantfiles, & Boxes


Set up a directory to house your projects. You could source-control it, too. Then make subdirectories for each project:

$ mkdir vagrantfiles && cd vagrantfiles
$ mkdir someproject && cd someproject

This is before you've added any boxes. The directories will hold your `Vagrantfile`s – not your boxes. The base boxes (or .img files) live in ~/.vagrant.d/boxes, and are base images. When you set up a project, you'll be building on top of that base image. This allows sharing of one base image across multiple projects. So, pick a base you'd like to use a lot, and you'll save space on your hardrive.

Decide which box you want. You can look at available boxes from hashicorp here: https://atlas.hashicorp.com/boxes/search. Clicking on a box will show you more useful info, like the init command to use to get that box.

I want to use Fedora and libvirt (see Vagrant with Libvirt (on Fedora)), so I'm looking at https://atlas.hashicorp.com/fedora/boxes/23-cloud-base.  Let's init our project:

$ vagrant init fedora/23-cloud-base

If this is the first time you've used this box, it will download the base image. When it completes, you'll see a Vagrantfile in your directory.  If you want to do additional config, change your Vagrantfile first. The default one will get you a working VM with host networking, so that's good enough for me.

Now, up your box:
$ vagrant up --provider libvirt               # watch the config & start
$ sudo virsh list –all                               # see that your box is now running
$ vagrant ssh                                         # access your machine

For more, definitely read the Vagrant docs: https://www.vagrantup.com/docs/getting-started

Vagrant with Libvirt (on Fedora)

Installing the Plugin

There is a project to use libvirt instead of the default (Virtualbox) with Vagrant: https://github.com/pradels/vagrant-libvirt. The project instructions say to use the vagrant command to install the libvirt plugin. However, for Fedora at least, you should use dnf to install the plugin:

$ dnf install vagrant-libvirt

Box Configuration

As opposed to the Virtualbox provider, if you want to update some VM properties (e.g. VCPUs or memory), you'll need to use virsh (read: do it outside of Vagrant).

The default memory is 512M, which isn't going to cut it for my purposes. so I've gone back and updated my VM. In the future, I'll remember to add the following to my Vagrantfile *before* I 'vagrant up.'

config.vm.provider :libvirt do |libvirt|   
      libvirt.memory = 2048
end