Skip to content

Instantly share code, notes, and snippets.

@gwokae
Forked from tobiassjosten/prompt.sh
Last active September 5, 2021 06:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwokae/5704576 to your computer and use it in GitHub Desktop.
Save gwokae/5704576 to your computer and use it in GitHub Desktop.
to quickly init my ubuntu dev environment

to boostrap my dev environment :D

configure system

install packages

# virtualbox
sudo apt-get update && sudo apt-get install apt build-essential htop git gitk gitg vim curl wget tmux meld virtualbox-guest-dkms virtualbox-guest-x11

# for X enabled
sudo apt-get update && sudo apt-get install apt build-essential htop git gitk gitg vim curl wget tmux meld

# for no X enabled
sudo apt-get update && sudo apt-get install apt build-essential htop git vim curl wget tmux

# ubuntu desktop - remove shopping lens
sudo apt-get remove unity-webapps-common
# gen key
ssh-keygen -t rsa 

# more secure, less compatibility 
ssh-keygen -t ed25519

fonts

# frequently used fonts
sudo apt-get install ttf-dejavu ttf-liberation

# optional MS-fonts
sudo apt install ttf-mscorefonts-installer

# refresh fonts 
sudo fc-cache -f -v

Config git

user

Just don't copy/paste this if you're not me!

git config --global user.name "Leonard Lin"
git config --global user.email "gwokae@gmail.com"

You can copy/paste this and configure correct information.

git config --global user.name ""
git config --global user.email ""

config

git config remote.origin.prune true
git config --global pager.stash false

git alias

git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch
git config --global alias.di diff
git config --global alias.brt "branch --sort=committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'"

Other issues

config git diff / git mergetool

Diff script reference

wget https://gist.githubusercontent.com/gwokae/5704576/raw/5209dae450b2fd81c873b1b6dc64a6a85a6d0311/git-diff.sh -P ~
chmod a+x ~/git-diff.sh
git config --global diff.external ~/git-diff.sh
git config --global merge.tool meld

download

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

vim ~/.bashrc and add following

test -f ~/.git-completion.bash && . $_

install hg

config

~/.hgrc

[ui]
# Name data to appear in commits
username = Leonard Lin <gwokae@gmail.com>
ignore = ~/.hgignore

[alias]
br = branch
brs = branches
he = histedit

[extensions]
rebase =
histedit =
prompt = /Users/leonard.lin/workspace/hg-prompt/prompt.py

install node manager

I prefere to manage node versions with nvm, node version manager. (Alternatively, you can use n )

Alrought nvm is seldomly required to update. But I still suggest to manually install.

1. checkout nvm git repo

git clone https://github.com/creationix/nvm.git ~/.nvm
cd ~/.nvm
git checkout $(git describe --abbrev=0) # last tagged version

2. activate nvm. You can copy-paste and modify following code and append to your ~/.bashrc

# nvm
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

3. install node & make alias

nvm install --lts

frequently used packages

npm install -g jshint eslint grunt-cli gulp 

This prompt settings is used in my Ubuntu. It displays the git repo's branch and colored status.

Hope you can enjoy it.

Zsh + Oh My Zsh

Windows Terminal

{
  "name": "JetBrains Darcula",
  "black": "#000000",
  "red": "#fa5355",
  "green": "#126e00",
  "yellow": "#c2c300",
  "blue": "#4581eb",
  "purple": "#fa54ff",
  "cyan": "#33c2c1",
  "white": "#adadad",
  "brightBlack": "#555555",
  "brightRed": "#fb7172",
  "brightGreen": "#67ff4f",
  "brightYellow": "#ffff00",
  "brightBlue": "#6d9df1",
  "brightPurple": "#fb82ff",
  "brightCyan": "#60d3d1",
  "brightWhite": "#eeeeee",
  "background": "#202020",
  "foreground": "#adadad",
  "selectionBackground": "#1a3272",
  "cursorColor": "#ffffff"
}

Bash

Gist: prompt.sh

cd ~
curl -O https://gist.githubusercontent.com/gwokae/5704576/raw/prompt.sh
echo "[[ -s \"$HOME/prompt.sh\" ]] && source \"$HOME/prompt.sh\" # prompt" >> .bashrc
bash

Home Brew

Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Formula

brew install git vim tmux wget

Casks

brew cask install iterm2 skype slack sublime-text visual-studio-code sourcetree

iTerm2

Sublime in OSX

command line

cd /usr/local/bin/
ln -sf /Applications/Sublime Text.app/Contents/SharedSupport/bin/subl subl

enable

// If true, the selected text will be copied into the find panel when it's
// shown.
// On OS X, this value is overridden in the platform specific settings, so
// you'll need to place this line in your user settings to override it.
"find_selected_text": true,

--fix sublime home and end key-- ref

this could use cmd + arrow keys to replace

Open Preferences > Key Bindings - User and add following lines

{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} },
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } }

bash

edit ~/.bash_profile

# alias
alias ls="ls -G"
alias ll="ls -al"
alias stree='open -a SourceTree' # optional
alias zip='zip -x "*.DS_Store"'

[ -r ~/.bashrc ] && source ~/.bashrc

meld

cd /usr/local/bin/
ln -sf /Applications/Meld.app/Contents/MacOS/Meld meld

with hg

vim ~/.hgrc

[ui]
merge = meld

[merge-tools]
meld.priority = 1
# meld.premerge = False
meld.args = $local $other $base

[merge-patterns]
** = meld
#!/bin/bash
# reference: http://lukas.zapletalovi.com/2012/09/three-way-git-merging-with-meld.html
meld "$2" "$5" > /dev/null 2>&1
# Configure colors, if available.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\e[0;32m\]'
c_host='\[\e[1;30m\]'
c_path='\[\e[1;34m\]'
c_git_clean='\[\e[0;37m\]'
c_git_staged='\[\e[0;32m\]'
c_git_unstaged='\[\e[0;31m\]'
else
c_reset=
c_user=
c_host=
c_path=
c_git_clean=
c_git_staged=
c_git_unstaged=
fi
# Add the titlebar information when it is supported.
case $TERM in
xterm*|rxvt*)
TITLEBAR='\[\e]0;\u@\h: \w\a\]';
;;
*)
TITLEBAR="";
;;
esac
# Function to assemble the Git parsingart of our prompt.
git_prompt ()
{
GIT_DIR=`git rev-parse --git-dir 2>/dev/null`
if [ -z "$GIT_DIR" ]; then
return 0
fi
GIT_HEAD=`cat $GIT_DIR/HEAD`
GIT_BRANCH=${GIT_HEAD##*/}
if [ ${#GIT_BRANCH} -eq 40 ]; then
GIT_BRANCH="(no branch)"
fi
STATUS=`git status --porcelain`
if [ -z "$STATUS" ]; then
git_color="${c_git_clean}"
else
echo -e "$STATUS" | grep -q '^ [A-Z\?]'
if [ $? -eq 0 ]; then
git_color="${c_git_unstaged}"
else
git_color="${c_git_staged}"
fi
fi
echo "[$git_color$GIT_BRANCH$c_reset]"
}
# to enable hg prompt http://sjl.bitbucket.org/hg-prompt/
hg_ps1() {
hg st > /dev/null 2>&1
if [ $? -ne 0 ]; then
return 0
fi
if [ -z $(hg prompt "{status}") ]; then
hg_color="${c_git_clean}"
else
hg_color="${c_git_unstaged}"
fi
hg prompt "[$hg_color{root|basename}{/{branch}}$c_reset]{ ({bookmark})}" 2> /dev/null
}
# Thy holy prompt.
PROMPT_COMMAND="$PROMPT_COMMAND PS1=\"${TITLEBAR}${c_user}\u${c_reset}@${c_host}\h${c_reset}:${c_path}\w${c_reset} \$(git_prompt)\$(hg_ps1)\$ \" ;"

h3. Package Control

https://packagecontrol.io/installation

h3. Packages

# common
Themr, Theme - Gravity,  Emmet, EditorConfig, Color Highlighter, ChangeQuotes, BracketHighlighter, SideBarEnhancements, Naomi, Terminus
# React.js
SublimeLinter, SublimeLinter-eslint, SCSS, JSX, CSS3, DocBlockr

monospace ligatures font JetBrains Mono, DejaVu Sans Code , FiraCode , or cascadia-code

h3.

{
  "binary_file_patterns":
  [
    "*.dds",
    "*.eot",
    "*.gif",
    "*.ico",
    "*.jar",
    "*.jpeg",
    "*.jpg",
    "*.pdf",
    "*.png",
    "*.swf",
    "*.tga",
    "*.ttf",
    "*.zip",
    "node_modules/**"
  ],
  "color_scheme": "Packages/User/Seti_monokai (SL).tmTheme",
  "default_line_ending": "unix",
  "draw_white_space": "all",
  "file_exclude_patterns":
  [
    ".git*",
    ".project"
  ],
  "folder_exclude_patterns":
  [
    ".git",
		".parcel-cache"
  ],
  "font_face": "JetBrains Mono",
  "font_size": 14,
  "ignored_packages":
  [
    "Vintage"
  ],
  "theme": "Gravity.sublime-theme",
  "color_scheme": "Packages/Theme - Gravity/Monokai Gravity.tmTheme",
  "lint_on_save": true,
  "node_path": "/C/Program Files/nodejs/node",
  "tab_size": 2,
  "translate_tabs_to_spaces": true,
  "trim_trailing_white_space_on_save": true
}

h3. key Bindings

[
  { "keys": ["ctrl+shift+g"], "command": "find_prev" },
  { "keys": ["ctrl+g"], "command": "find_next" },
  { "keys": ["ctrl+alt+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
  { "keys": ["ctrl+alt+p"], "command": "prompt_select_workspace" },
  { "keys": ["ctrl+alt+`"], "command": "toggle_terminus_panel"}
]

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"profiles":
[
{
"guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl",
"fontFace":"Cascadia Code",
"fontSize":12,
"useAcrylic": true,
"acrylicOpacity": 0.8,
"colorScheme" : "One Half Dark",
"icon":"C:/Users/gwokae/Documents/ubuntu.png"
},
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
}
],
// Add custom color schemes to this array
"schemes": [],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": [
{ "command" : "closeTab", "keys": ["ctrl+w"] },
{ "command": "copy", "keys": ["ctrl+shift+c"] },
{ "command": "paste", "keys": ["ctrl+shift+v"] }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment