Skip to content

Instantly share code, notes, and snippets.

@digitalnomad91
Created May 12, 2023 16:21
Show Gist options
  • Save digitalnomad91/77e6f0454bac4b7d1946c3ab078bbf70 to your computer and use it in GitHub Desktop.
Save digitalnomad91/77e6f0454bac4b7d1946c3ab078bbf70 to your computer and use it in GitHub Desktop.
zsh_alises
#!/bin/bash
alias shopt='/usr/bin/shopt'
shopt -s expand_aliases
#zsh aliases
alias ohmyzsh="nano ~/.oh-my-zsh"
alias reload='source ~/.zshrc'
alias zshconfig='nano $HOME/.zshrc'
alias byt="cd /home/digitalnomad91/byt"
# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
export TERM=xterm-256color
#
# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
#search in files for a word
alias search='grep -liR '
#history shortcuts
alias h='history'
alias hs='history | grep'
alias hsi='history | grep -i'
#node.js quirk with older versions
alias nodelegacy="export NODE_OPTIONS=--openssl-legacy-provider"
alias y='yarn'
alias yolo='rm -rf node_modules/ && rm package-lock.json && yarn install'
# alias for finding which process a particular port is running from
alias port='sudo lsof -i -P -n | grep LISTEN | grep'
alias myip='curl http://ipecho.net/plain; echo'
#tor
alias newidentity="echo -e 'AUTHENTICATE ""\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051 && torify curl ifconfig.me 2>/dev/null"
#A global alias to pipe a command’s output to less:
alias L='| less'
#A global alias to pipe a command’s output to grep:
alias G='| grep'
#An alias to kick off a server in your current directory (no npm packages required):
alias pyserver='python3 -m SimpleHTTPServer 8000'
#distro output
alias distro='cat /etc/*-release'
# Search through your command history and print the top 10 commands
alias historystats="history 0 | awk "{print $2}" | sort | uniq -c | sort -n -r | head"
# Use `which` to find aliases and functions including binaries
which='(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot'
#show a function
alias pfunc="whence -f"
# catch stdin, pipe it to stdout and save to a file
function catch () {
cat - | tee /tmp/catch.out
}
# print whatever output was saved to a file
function res () {
cat /tmp/catch.out
}
function petsc {
netstat "$@"
}
#github aliases
alias gs='git status'
alias gp='git pull'
alias gph='git push'
alias gd='git diff | mate'
alias gau='git add --update'
alias gc='git commit -m'
alias gca='git commit -v -a'
alias gb='git branch'
alias gba='git branch -a'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcot='git checkout -t'
alias gcotb='git checkout --track -b'
alias glog='git log'
alias glogp='git log --pretty=format:"%h %s" --graph'
alias gfo='git fetch origin'
alias gitlg='git log --graph --pretty=format:'\''%Cred%h%Creset -
%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-
commit'
alias undo-git-reset-head="git reset 'HEAD@{1}'"
#An alias to update package lists
alias sapu='sudo apt-get update'
#n alias to rerun the previous command with sudo
alias ffs='sudo !!'
#windows netstat packages
alias netstat='/mnt/c/Windows/System32/netstat.exe'
alias pktmon='/mnt/c/Windows/System32/pktmon.exe'
#Interactive git diff
function gdi() {
git log --graph --color=always \
--format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" \
| fzf --ansi --preview "echo {} \
| grep -o '[a-f0-9]\{7\}' \
| head -1 \
| xargs -I % sh -c 'git show --color=always %'" \
--bind "enter:execute:
(grep -o '[a-f0-9]\{7\}' \
| head -1 \
| xargs -I % sh -c 'git show --color=always % \
| less -R') << 'FZF-EOF'
{}
FZF-EOF"
}
#Show website certificate from hostname
function curl-cert() {
openssl s_client -showcerts -connect "${1}":443 -servername ${1}
}
#Interactive man search
function mans(){
man -k . \
| fzf -n1,2 --preview "echo {} \
| cut -d' ' -f1 \
| sed 's# (#.#' \
| sed 's#)##' \
| xargs -I% man %" --bind "enter:execute: \
(echo {} \
| cut -d' ' -f1 \
| sed 's# (#.#' \
| sed 's#)##' \
| xargs -I% man % \
| less -R)"
}
#The most important functions
function disappointed() { echo -n " ?_? " |tee /dev/tty| xclip -selection clipboard; }
function flip() { echo -n "(?°?°)? ???" |tee /dev/tty| xclip -selection clipboard; }
function shrug() { echo -n "¯\_(?)_/¯" |tee /dev/tty| xclip -selection clipboard; }
function matrix2() { echo -e "\e[1;40m" ; clear ; while :; do echo $LINES $COLUMNS $(( $RANDOM % $COLUMNS)) $(( $RANDOM % 72 )) ;sleep 0.05; done|awk '{ letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"; c=$4; letter=substr(letters,c,1);a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1; printf "\033[%s;%sH\033[2;32m%s",o,x,letter; printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,letter;if (a[x] >= $1) { a[x]=0; } }}' }
#lowercase
function lowercase() {
echo ${1:l}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment