Ubuntu vimrc and setting tab to 4 spaces

On ubuntu .vimrc already exists in /usr/share/vim/vimrc. So in bash copy this file into your home directory like so:

cp /usr/share/vim/vimrc ~/.vimrc

To set tab to 4 spaces, open your vimrc file and add the following at the bottom of the file:

filetype plugin indent on
set tabstop=4
set shiftwidth=4
set expandtab

Here is a discussion on stackoverflow of various possibilities for setting tab/whitespace width in your vimrc.

Atom with script package

Using Sublime Text I got used to using ctrl-b to “build” python. Now that I have started using Atom more I wanted this functionality for Atom too. Turns out, the package called “script” does this: https://atom.io/packages/script

First off, open your files from the powershell command line rather than by double clicking the Atom Icon. The Script package can be installed using apm install script (yes, this works in powershell under Windows!).


Change git remote url

From the bash git command line check to see what the original origin url is:

 git remote -v 

The output will look something like this:

origin gituser@domainname.com:/home/gituser/repo.git (fetch)
origin gituser@domainname.com:/home/gituser/repo.git (push)

To change that url you run this command:

git remote set-url origin gituser@newdomainname.com:/home/gituser/repo.git

ssh without Password prompt in Windows: ssh-copy-id

Use an ssh public key instead of having to type a password all of the time. The main thing that makes this a hassle in git bash/windows is that there is no ssh-copy-id command available.

1. Generate an ssh key using git bash (https://help.github.com/articles/generating-ssh-keys/):

ssh-keygen -t rsa -b 4096 -C “your_email@example.com”

2. Use this python script in git bash to copy the id_rsa.pub to the authorized keys on the remote server.

Had to comment out the mkdir and touch at lines 39 and 40 because my server already has those but otherwise the script does what it says.

3. In git bash run and follow the prompts. You will end up putting in your ssh password a couple of times but then thereafter you won’t have to.

python ssh-copy-id.py user@sshserver.com