Skip to content

colinxy/dotfiles

Repository files navigation

Emacs

Config file is .emacs.d/init.el Packages are setup with use-package. Most packages are not ensured (automatically downloaded). To download everything, uncomment the following line and restart emacs.

(setq use-package-always-ensure t)

On an environment with limited needs, use .emacs.min as config file.

Emacs on Mac

brew tap railwaycat/emacsmacport
brew install emacs-mac --with-imagemagick --with-modules --with-xml2 --with-modern-icon

To launch GUI emacs, add the following file emacs to somewhere in PATH, and make sure executable bit is on

#!/bin/bash
exec /usr/local/opt/emacs-mac/Emacs.app/Contents/MacOS/Emacs "$@"

Disable some slow GUI components. Reference: radian-software/radian#180

defaults write org.gnu.Emacs Emacs.ToolBar -string no
defaults write org.gnu.Emacs Emacs.ScrollBar -string no

Emacs on Linux

Disable useless GUI components. Reference same as above, also https://www.gnu.org/software/emacs/manual/html_node/emacs/Table-of-Resources.html

See .Xresources for details. Use the below command to reload the resource file.

xrdb -merge ~/.Xresources

Emacs in Terminal

control sequence get pasted with Command-v

bracketed paste mode https://cirw.in/blog/bracketed-paste

ChrisJohnsen/tmux-MacOSX-pasteboard#31

xclip-mode solves the problem? It replied on pbcopy/pbpaste on mac, and xclip on linux (sudo apt-get install xclip).

Tmux

on mac

problems with copy/paste, opening graphical applications

solution: https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard

brew install reattach-to-user-namespace
if-shell 'test "$(uname -s)" = Darwin' 'set-option -g default-command "exec reattach-to-user-namespace -l $SHELL"'

Python

Install pip

use --user if no admin privilege

Method 1

wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
python ez_setup.py --user > /dev/null
easy_install --user pip

Method 2

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user

Add config file and environment variable to silence warning

environment variable: PIP_CONFIG_FILE=$HOME/.config/pip/pip.conf

[global]
timeout=3

[list]
format=columns

Additional python package for emacs elpy to work properly

use pip3 for python3 packages

# if use python instead of ipython, remove (elpy-use-ipython) from .emacs
pip install --user ipython
# for elpy completion and error detection
pip install --user jedi importmagic flake8

Upgrade python packages

To see outdated packages

pip list --outdated

Upgrade all outdated packages

pip supports multiple arguments, so -n1 option to xargs is not needed. If format option to pip is set to columns, skip first 2 lines in pip list --outdated output (start printing from the 3rd line).

pip  list --outdated | tail -n +3 | awk '{print $1}' | xargs pip  install -U
pip3 list --outdated | tail -n +3 | awk '{print $1}' | xargs pip3 install -U

To see the command composed by xargs before executing it, use xargs [xargs-options] echo [command].

Note on Python Packages as Executable Scripts

Most packages are available for both python2 and python3 under the same name, while at the same time, they are linked as an executable in /usr/local/bin. It is sometimes confusing whether you are using python 2 or 3 package if directly invoked from command line.

Since I prefer python3 to python2, first upgrade python 2 packages, then upgrade python3 packages, so that python3 packages would overwrite python2 ones in /usr/local/bin.

When trying to run a tool only under python 2/3, use the following.

python  -m flake8
python3 -m flake8

Pyenv

apt-get build-dep python3
# install pyenv
# curl: from github
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

C/C++

gdb-dashboard

wget -P ~ git.io/.gdbinit

Clang

# on Mac
brew install llvm --with-clang
# on ubuntu
apt-get install llvm-dev clang libclang-dev

Tools

brew install cmake
apt-get install cmake

emacs irony-mode

M-x irony-install-server: Make sure to specify the following

-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang

man pages

amazing c++ documentation, from https://github.com/jeaye/stdman

brew install stdman

Javascript

Runtime and Package Manager

  • nodejs, npm
# Mac
brew install nodejs npm
# ubuntu
apt-get install nodejs npm
# for ubuntu, node might have to be symlinked
ln -s /usr/bin/nodejs /usr/bin/node
  • npm install user global: https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md
    • local directory
      mkdir "${HOME}/.npm-packages"
      
              
    • add to ~/.npmrc
      prefix=${HOME}/.npm-packages
              
    • add to .bashrc
      NPM_PACKAGES="${HOME}/.npm-packages"
      
      PATH="$NPM_PACKAGES/bin:$PATH"
      
      # Unset manpath so we can inherit from /etc/manpath via the `manpath` command
      unset MANPATH # delete if you already modified MANPATH elsewhere in your config
      export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
      
              

Linter: eslint, Completion: tern

# no need to sudo
npm install -g eslint tern
  • tern: add a default config under home directory
    // ~/.tern-project
    {
      "plugins": {
        "es_modules": {},
        "node": {}
      },
      "libs": [
        "ecma5",
        "ecma6"
      ],
      "ecmaVersion": 6
    }
    
        
  • eslint: add a default config under home directory
    // ~/.eslintrc.json
    {
      "env": {
        "browser": true,
        "node": true,
        "es6": true
      },
      "rules": {
        "no-use-before-define": "error"
      }
    }
    
        

Bash

On Mac

add ~/.bash_profile with

if [[ $- == *i* ]] && [ -r ~/.bashrc ]; then
    . ~/.bashrc
fi

Bash Powerline

pip install powerline-status

more stuff to do

Shell Scripting

shellcheck

brew install shellcheck
apt-get install shellcheck

Ruby

gem install pry robocop jekyll

Linux (mac)

ip command

For mac, emulate ip from Linux

brew tap brona/iproute2mac
brew install iproute2mac

Pastebin

https://github.com/defunkt/gist

IRC

ZNC bouncer

DATADIR=/var/lib/znc

sudo apt install znc znc-dev
getent passwd znc || sudo useradd znc
mkdir -p $DATADIR && chown -R znc:znc $DATADIR
sudo -u znc znc --makeconf --datadir $DATADIR

git clone https://github.com/jpnurmi/znc-playback.git
cd znc-playback/ && znc-buildmod playback.cpp
mkdir -p $DATADIR/modules && mv playback.so $DATADIR/modules
chown -R znc:znc ~/.znc         # permission issue
# then follow instructions here to activate the playback module
# https://wiki.znc.in/Playback

# start znc as follows
sudo -u znc znc --datadir $DATADIR

reference: https://www.andrewstambrosky.com/2016/11/19/znc-ubuntu-1604/

circe (emacs)

https://github.com/jorgenschaefer/circe/