Skip to content

Instantly share code, notes, and snippets.

@bcawrse
Last active May 24, 2023 19:48
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 bcawrse/f37fc4ba975e2b73c8dea468b6cbec38 to your computer and use it in GitHub Desktop.
Save bcawrse/f37fc4ba975e2b73c8dea468b6cbec38 to your computer and use it in GitHub Desktop.
Setup Zsh on fresh debian-based install
# General CLI utility.
alias la='ls -lAhF'
alias lar='ls -AhF'
alias ll='ls -lhF'
alias l='ls -hF'
alias cl='clear; lar'
alias c='clear;'
alias xg='xargs egrep -sin --color'
alias hostip="ip route get 0.0.0.0/0 | grep -Eo 'via \S+' | awk '{ print \$2 }'"
# Dev CLI utility
alias yun='yarn run'
alias nun='npm run'
# Git aliases outside of git.alias
alias cgs='clear; git status'
alias cgsh='clear; git status ./'
alias cgl='clear; git logall || git log --decorate --date-order --remotes --graph --tags --branches'
alias cglt='clear; git logthis || git log --decorate --date-order --graph --tags'
alias cgls='clear; git logalls || git log --decorate --date-order --remotes --graph --tags --branches --stat'
alias gl='git logall || git log --decorate --date-order --remotes --graph --tags --branches'
alias gd='git diff'
alias gdc='git diff --cached'
alias gs='git status'
alias gsl='git stash list | cat'
# git copy modified - requires destination
#alias gcm='git ls-files --modified | xargs -I {} cp -r {}'
# MAC VERSION
alias gcm='git ls-files --modified | xargs -I {} rsync -R {}'
# GitHub aliases
alias ghprc='gh pr create --web'
alias ghprv='gh pr view --web'
alias ghrc='gh repo create'
alias ghrv='gh repo view --web'
# Docker aliases
alias dockc='docker container'
alias docki='docker image'
alias dockv='docker volume'
alias dockn='docker network'
alias dcu='docker-compose up -d && docker-compose logs -f'
alias dcub='docker-compose up --build -d && docker-compose logs -f'
alias dcd='docker-compose down'
alias dcp='docker-compose pull'
alias dcl='docker compose logs -f'
alias dm-disk='docker run --rm -it -v \:\docker alpine:edge $@'
# dm-disk usage: 'dm-disk ls -l /docker/va/rlib/docker/volumes/
dcup () {
docker-compose --profile "$1" up -d && docker compose logs -f
}
dcubp () {
docker-compose --profile "$1" up --build -d && docker compose logs -f
}
# k8s aliases
alias kx='f() { [ "$1" ] && kubectl config use-context $1 || kubectl config current-context ; } ; f'
alias kn='f() { [ "$1" ] && kubectl config set-context --current --namespace $1 || kubectl config view --minify | grep namespace | cut -d" " -f6 ; } ; f'
# Tools and functions
alias hist='history | tail -25'
alias pshell="powershell.exe" # Useful in WSL | Windows Subsystem for Linux
alias frep="find ./ | xargs grep -P -sin --color"
frepe () {
local _find="/usr/bin/find"
$_find ./ -iname "*.$1" | xargs grep -P -sin --color $3 $2
}
alias starwars="telnet towel.blinkenlights.nl" # watch StarWars from command line
# Get weather for current location
# Swapped to function so can overload the rest of the URL.
# get help with ':help'
weather () {
curl http://wttr.in/$1
}
# Tools Notes
# ffmpeg great for converting / compressing videos
# convert from imageMagick will convert & compress images
# mogrify works like convert, except it overwrites the image in-place
alias image-optim='convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85%' # source.jpg result.jpg
# pandoc, the everything document converter. Even MarkDown to word docs!
# install zsh
sudo apt update && sudo apt install zsh
sudo chsh -s $(which zsh)
# install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# install Python & Pip
sudo apt install python
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python
sudo pip install git+git://github.com/Lokaltog/powerline
# install powerline fonts needed by most zsh themes
sudo apt install fonts-powerline python-powerline powerline
# download oh-my-zsh syntax highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
echo 'Turn on zsh-syntax-highlighting by adding zsh-syntax-highlighting plugin in ~/.zshrc file'
# TODO: do this instead of requiring
# download .aliases file and add to bottom of zsh config
curl -sSfL --retry 5 https://gist.githubusercontent.com/bcawrse/f37fc4ba975e2b73c8dea468b6cbec38/raw/.aliases > ${HOME:-~}/.aliases
echo "source ~/.aliases" >> ${HOME:-~}/.zshrc
# update global git config
sh -c "$(curl -fsSL https://gist.githubusercontent.com/bcawrse/366fc34ac7addbffca81a6bad291cc5e/raw/gitGlobalConfig.sh)"
# install keychain tool for auto-ssh and run from zsh config
sudo apt install keychain
echo "eval $(keychain --eval id_rsa)" >> ${HOME:-~}/.zshrc
# install other well-loved cli tools
sudo apt install tree
# enable PowerLine fonts etc
echo "if [ -f 'which powerline-daemon' ]; then" >> ${HOME:-~}/.zshrc
echo " powerline-daemon -q" >> ${HOME:-~}/.zshrc
echo " POWERLINE_BASH_CONTINUATION=1" >> ${HOME:-~}/.zshrc
echo " POWERLINE_BASH_SELECT=1" >> ${HOME:-~}/.zshrc
echo " source /usr/share/powerline/bindings/bash/powerline.sh" >> ${HOME:-~}/.zshrc
echo "fi" >> ${HOME:-~}/.zshrc
echo "Don't forget to setup system ssh key with ssh-keygen -t rsa"
# reminder to update sudoers file
echo "Remember to update sudo defaults with sudo visudo and add "
echo "Defaults editor=\"/usr/bin/vim\""
echo "Defaults insults"
@bcawrse
Copy link
Author

bcawrse commented Jun 18, 2019

To run, get the URL of the raw view and use
sh -c "$(curl -fsSL [RAW URL])"

sh -c "$(curl -fsSL https://gist.githubusercontent.com/bcawrse/f37fc4ba975e2b73c8dea468b6cbec38/raw/setupZsh.sh)"

@bcawrse
Copy link
Author

bcawrse commented Jun 24, 2019

Command highlighting, add zsh-syntax-highight to custom zsh plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md#oh-my-zsh

Activate the plugin in ~/.zshrc:
plugins=( [plugins...] zsh-syntax-highlighting)

@bcawrse
Copy link
Author

bcawrse commented Mar 1, 2021

Simple filename one liner
find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment