Skip to Content
All memories

Hetzner VPS Setup

Hetzner Cloud Setup

Cloudinit config

cloud-init.yml
#cloud-config

package_update: true
package_upgrade: true
package_reboot_if_required: true

apt:
    sources:
        docker:
            source: "deb [arch=amd64] https://download.docker.com/linux/debian buster stable"
            keyid: "9DC858229FC7DD38854AE2D88D81803C0EBFCD88" 

packages:
    - zsh
    - curl
    - git
    - ufw
    - apt-transport-https
    - ca-certificates
    - gnupg2
    - software-properties-common
    - docker-ce

users:
    - default
    - name: mokhtar
      gecos: Mokhtar Mial
      sudo: ALL=(ALL) NOPASSWD:ALL
      groups: docker
      shell: /usr/bin/zsh
      ssh_authorized_keys:
        - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3BGSYJSLukeo6SUKx3nxf8YYfqtJyloCgCeTn79TJr9HREeNoAlitEFuJkMQLFaKrwoMrsObZbZ+vbQ0ljbZtKfM/iPExXwCTdSuFI1MjNwEP2gyam9kt6pTNtwOKmc1dAyxRsZ6ISpowwdG1iXVBpAjjFkaIhH1GtH9wSB1Q2FISL8CwPeo8yAaKXHrmfXOwZNUau5c0vbaniUy4p0EwqYQrlkJdu9sR5RfRuC6YKKqSob7W6muAyuGvEO0mKIqaYCrM4pI9XFaJ3GiPYwhd1m1U+WScVkWkP4osSzcT5UTJajFAKjvkomvgX8ZewZSiGDcmLtToEUfl56lC6sOH mokhtar-laptop

runcmd:
    - ufw allow OpenSSH
    - ufw enable

ZSH theme

zeit.zsh-theme
local resetColor="%{$reset_color%}"
local logo="%{$fg_bold[white]%}▲$resetColor$resetColor"
local hostname=`hostname`
local dir="%{$fg_bold[white]%}%c$resetColor$resetColor"


GIT_PROMPT_PREFIX="[%{$fg_bold[white]%}"
GIT_PROMPT_SUFFIX="$resetColor] "
GIT_PROMPT_DIRTY="%{$fg_bold[red]%}"
GIT_PROMPT_CLEAN="%{$fg_bold[green]%}"

# modified from https://github.com/robbyrussell/oh-my-zsh/blob/576ada138fc5eed3f58a4aff8141e483310c90fb/lib/git.zsh#L12
function branch_is_dirty() {
  local STATUS=''
  local -a FLAGS
  FLAGS=('--porcelain')
  if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
    if [[ $POST_1_7_2_GIT -gt 0 ]]; then
      FLAGS+='--ignore-submodules=dirty'
    fi
    if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
      FLAGS+='--untracked-files=no'
    fi
    STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
  fi
  if [[ -n $STATUS ]]; then
    return 0
  else
    return 1
  fi
}

function git_prompt() {
  branch=`git_current_branch`
  if [ "$branch" = '' ]; then
    # not a git repo
    echo ''
  else
    if branch_is_dirty; then
      echo "$GIT_PROMPT_PREFIX$GIT_PROMPT_DIRTY$branch$GIT_PROMPT_SUFFIX"
    else
      echo "$GIT_PROMPT_PREFIX$GIT_PROMPT_CLEAN$branch$GIT_PROMPT_SUFFIX"
    fi
  fi

}
PROMPT='$logo $dir $(git_prompt)'