Menu Close

devstate.de

A Dreams Engine Blog. This Blog may not make any sense to you. This is a collection of internal snippets that we collect with our experiences, but we hope some of our post will help you in some way.

Pimp my terminal with Zinit – 2022

Install Zinit

sh -c "$(curl -fsSL <https://git.io/zinit-install>)"

Create a .zshrc

vim ~/.zshrc

Copy the next code to .zshrc file:

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
### Added by Zinit's installer
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.zinit/bin" && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
#####################
# PROMPT #
#####################
zinit ice from"gh-r" as"command" atload'eval "$(starship init zsh)"'
zinit load starship/starship
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zdharma-continuum/zinit-annex-rust \
zdharma-continuum/zinit-annex-as-monitor \
zdharma-continuum/zinit-annex-patch-dl \
zdharma-continuum/zinit-annex-bin-gem-node
### End of Zinit's installer chunk
##########################
# OMZ Libs and Plugins #
##########################
# IMPORTANT:
# Ohmyzsh plugins and libs are loaded first as some these sets some defaults which are required later on.
# Otherwise something will look messed up
# ie. some settings help zsh-autosuggestions to clear after tab completion
setopt promptsubst
# Loading tmux first, to prevent jumps when tmux is loaded after .zshrc
# It will only be loaded on first start
zinit wait lucid for \
OMZL::clipboard.zsh \
OMZL::compfix.zsh \
OMZL::completion.zsh \
OMZL::correction.zsh \
atload"
alias ..='cd ..'
alias …='cd ../..'
alias ….='cd ../../..'
alias …..='cd ../../../..'
" \
OMZL::directories.zsh \
OMZL::git.zsh \
OMZL::grep.zsh \
OMZL::history.zsh \
OMZL::key-bindings.zsh \
OMZL::spectrum.zsh \
OMZL::termsupport.zsh \
atload"
alias gcd='gco dev'
" \
OMZP::git \
atload"
alias dcupb='docker-compose up –build'
" \
OMZP::docker-compose \
as"completion" \
OMZP::docker/_docker \
djui/alias-tips \
# hlissner/zsh-autopair \
# chriskempson/base16-shell \
#####################
# PLUGINS #
#####################
# @source: https://github.com/crivotz/dot_files/blob/master/linux/zplugin/zshrc
# IMPORTANT:
# These plugins should be loaded after ohmyzsh plugins
zinit wait lucid for \
zsh-users/zsh-history-substring-search \
light-mode atinit"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20" atload"!_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions \
light-mode atinit"typeset -gA FAST_HIGHLIGHT; FAST_HIGHLIGHT[git-cmsg-len]=100; zpcompinit; zpcdreplay" \
zdharma-continuum/fast-syntax-highlighting \
light-mode blockf atpull'zinit creinstall -q .' \
atinit"
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' menu select=2
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
zstyle ':completion:*:descriptions' format '– %d –'
zstyle ':completion:*:processes' command 'ps -au$USER'
zstyle ':completion:complete:*:options' sort false
zstyle ':completion:*:*:*:*:processes' command 'ps -u $USER -o pid,user,comm,cmd -w -w'
" \
zsh-users/zsh-completions \
bindmap"^R -> ^H" atinit"
zstyle :history-search-multi-word page-size 10
zstyle :history-search-multi-word highlight-color fg=red,bold
zstyle :plugin:history-search-multi-word reset-prompt-protect 1
" \
zdharma-continuum/history-search-multi-word \
reset \
atclone"dircolors -b LS_COLORS > clrs.zsh" \
atpull'%atclone' pick"c.zsh" nocompile'!' \
atload'zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS}”' \
trapd00r/LS_COLORS
# Load powerlevel10k theme
zinit ice depth"1" # git clone depth
zinit light romkatv/powerlevel10k
# Load pure theme
zinit ice pick"async.zsh" src"pure.zsh" # with zsh-async library that's bundled with it.
zinit light sindresorhus/pure
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
#####################
# HISTORY #
#####################
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
HISTSIZE=290000
SAVEHIST=$HISTSIZE
#####################
# SETOPT #
#####################
# set -o emacs
# setopt vi
setopt extended_history # record timestamp of command in HISTFILE
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_all_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
setopt inc_append_history # add commands to HISTFILE in order of execution
setopt share_history # share command history data
setopt always_to_end # cursor moved to the end in full completion
setopt hash_list_all # hash everything before completion
setopt completealiases # complete alisases
setopt always_to_end # when completing from the middle of a word, move the cursor to the end of the word
setopt complete_in_word # allow completion from within a word/phrase
setopt nocorrect # spelling correction for commands
setopt list_ambiguous # complete as much of a completion until it gets ambiguous.
setopt nolisttypes
setopt listpacked
setopt automenu
setopt autocd
#####################
# ENV VARIABLE #
#####################
ZSH_AUTOSUGGEST_MANUAL_REBIND=1 # make prompt faster
DISABLE_MAGIC_FUNCTIONS=true # make pasting into terminal faster
export EDITOR=vim
export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
#####################
# ALIASES #
#####################
alias vim=$EDITOR
alias tf=terraform
alias l="exa -abghHlS –git –group-directories-first"
alias ipInternal=ip-internal
alias ipExternal=ip-external
alias ls='ls -G'
alias ll='ls -lG'
alias lsd='ls -haltr'
# Shell
alias reload!='exec "$SHELL" -l'
alias MyBook="cd /Volumes/MyBook"
# Docker
alias dk="docker-compose"
alias dkpurge="docker stop $(docker ps -aq) && docker rm $(docker ps -aq) && docker rmi $(docker images -q)"
# VSCode
alias code="code-insiders";
# Tmux
alias stmx="tmux attach -t base || tmux new -s base"
# Aliases
alias zshrc="vim $HOME/.zshrc"
alias zshp="vim $HOME/.zsh_plugins.txt"
alias aliax="vim $HOME/.aliases"
alias vimx="vim $HOME/.vimrc"
alias desk="cd $HOME/Desktop"
alias tumx="vim $HOME/.tmux.conf"
alias dev="cd $HOME/Development/"
alias %dev='_dev_(){~/Volumes/MyBook/"$1".*}; _dev_'
# Tmux
alias %t='_tmux_(){tmux new -s "$1"}; _tmux_'
alias sshrc="vim $HOME/.ssh/config"
alias python=/opt/homebrew/bin/python3
#npm
alias npmnuke="echo Deleting ^/node_modules/ && rm -rf ./**/node_modules"
#####################
# Functions #
#####################
# echo "Ethernet :: IP => $( ip -4 -o a show wlan1 | awk '{ print $4 }' )"
ip-internal() echo "Wireless :: IP => $( ipconfig getifaddr en0 )"
ip-external() echo "External :: IP => $( curl –silent https://ifconfig.me )"
ipinfo() { ipInternal && ipExternal }
#####################
# Misc Stuff #
#####################
# typeset -U config_files
# config_files=($HOME/.zsh/*.zsh)
# 1. Load anything which ends with e.zsh
# 2. Load anything except file ending with e.zsh
# zinit is-snippet for \
# ${(M)config_files:#*/*e.zsh} \
# ${config_files:#*/*e.zsh} \
zinit is-snippet for \
if"[[ -f $HOME/.localrc ]]" $HOME/.localrc
#####################
# Exports #
#####################
# https://blog.josephscott.org/2015/05/18/lscolors/
export LSCOLORS=GxFxCxDxbxegedabagaced
view raw .zshrc.zinit hosted with ❤ by GitHub

Before copy, make sure VIM is correctly configured

:set paste
CMD+V

Save the .zshrc file

:wq!

Close iterm2

CMD+Q

Open again iterm2

Follow the instructions on the terminal window, if everything went well you will see something like the next screenshot.

This is how my terminal looks:

Configura tu Mac

##HOMEBREW

Primero que nada recomendamos leer mas de :

Homebrew

Puedes instalar tu software de la manera tradicional o ser ninja:

Por medio de tu terminal ejecutamos los siguiente comandos

Posiblemente el Apple’s Command Line Tools se instale automático pero hagamos esto por si las dudas,

xcode-select --install

Instala Homebrew en tu Mac:

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

Si Brew se instala satisfactoriamente, ahora pasemos a instalar software.

Para instalar software solo necesitas:

brew install --cask slack
brew install -—cask visual-studio-code
brew install —-cask google-chrome
brew install —-cask firefox-developer-edition
brew install --cask iterm2
brew install --cask docker

Importante, ya que instalamos iterm2 que es la mejor app en remplazo de tu terminal de Apple.

Puedes seguir estas instrucciones para pimpear tu terminal:

Terminal

##SSH-KEY

Crea tu SSH-KEY

  1. Abre tu terminal
  2. ssh-keygen -t ed25519 -C "[email protected]"
  3. Normalmente debemos de ponerle enter a todo, no es necesario escribir o añadir algo.
  4. Añade tu Key al ssh-agent: eval "$(ssh-agent -s)" ssh-add -K ~/.ssh/id_ed25519
  5. Ahora puedes copiar tu nueva key con el siguiente comando: pbcopy < ~/.ssh/id_ed25519.pub

Simple ZSH Theme

# DESCRIPTION:
#   A simple zsh configuration that gives you 90% of the useful features that I use everyday.
#
# AUTHOR:
#   Geoffrey Grosenbach http://peepcode.com



# Colors
autoload -U colors
colors
setopt prompt_subst

# Prompt
local smiley="%(?,%{$fg[green]%}☺%{$reset_color%},%{$fg[red]%}☹%{$reset_color%})"

PROMPT='
%~
${smiley}  %{$reset_color%}'

Hombrew OSX

Before Everything:

brew update
brew upgrade

Fix Permissions

sudo chown -R $(whoami):admin /usr/local

Install Vim 8

brew install vim --override-system-vim

Install PHP7.1 (20.03.17)

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php71

Install Latest Rsync

brew tap homebrew/dupes
brew install rsync
brew link rsync

Install Latest Tmux

brew install tmux

 

Fixing Ubuntu Random Issues

Fixing NO_PUBKEY:

W: GPG error: http://ppa.launchpad.net precise
Release: The following signatures couldn’t be verified because the public key is not available:
NO_PUBKEY 2EA8F35793D8809A

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
or for EasyEngine:

apt-key adv --keyserver keyserver.ubuntu.com --recv 3050AC3CD2AE6F03

 

 

Fixing PIP / Letsencrypt Error:

OSError: Command /root/.local/share/letsencrypt/bin/python2.7 – setuptools pkg_resources pip wheel failed with error code 2

If you don’t have Python…Install it

Update:

sudo apt update && sudo apt-get -y upgrade

 

Install Python

sudo apt install python-pip

 

Fixit:

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"

 

more “fixes” to come

Useful commands for Docker

Enter Bash of your Docker

docker exec -it docker_wordpress_1 bash

Delete All Images & Containers

#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)

Docker+WP

Create a

docker-compose.yml

file in a any folder

i.e.

/Documents/Docker/mydomainsample.com/docker-compose.yml
docker-compose.yml
version: '2'

services:
 wordpress:
 depends_on:
 - mysql
 image: wordpress:php7.0
 ports:
 - "8080:80"
 volumes:
 - ./htdocs/assets:/var/www/html/wp-content
 links:
 - mysql
 environment:
 WORDPRESS_DB_HOST: mysql:3306
 WORDPRESS_DB_PASSWORD: wp

 mysql:
 image: mariadb:10.1.19
 ports:
 - "8081:3306"
 volumes:
 - ./databases:/var/lib/mysql
 environment:
 MYSQL_ROOT_PASSWORD: wp

Know Issues

WordPress Docker not starting or closing unexpectedly:

This happen because the MySQL docker database doesn’t have the necessary permissions:

Step 1: Access the docker cluster:

docker exec -it my_wordpress_mysql_docker_cluster bash

Step 2: Access MySQL:

msyql -uroot -pwp

Step 3: Allow MySQL WordPress User to access the databases:

GRANT ALL ON *.* to [email protected]'%' IDENTIFIED BY 'wp';
Older Posts