diff options
| author | Akshay Nair <phenax5@gmail.com> | 2020-12-20 16:49:47 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2020-12-20 16:49:47 +0530 |
| commit | 568f7903ca7464f99df659b8488bd731e4f2c4f0 (patch) | |
| tree | dfa7f9d077eb85ec840c8bfcaa04c1d64cc5aa29 /external/zsh/aliases | |
| parent | c580a9ec2a1a43a682117eca41c3867e8771117a (diff) | |
| download | nixos-config-568f7903ca7464f99df659b8488bd731e4f2c4f0.tar.gz nixos-config-568f7903ca7464f99df659b8488bd731e4f2c4f0.zip | |
Adds zsh config
Diffstat (limited to 'external/zsh/aliases')
| -rw-r--r-- | external/zsh/aliases/dev.zsh | 24 | ||||
| -rw-r--r-- | external/zsh/aliases/dir.zsh | 27 | ||||
| -rw-r--r-- | external/zsh/aliases/edit.zsh | 17 | ||||
| -rw-r--r-- | external/zsh/aliases/git.zsh | 70 | ||||
| -rw-r--r-- | external/zsh/aliases/ls.zsh | 22 | ||||
| -rw-r--r-- | external/zsh/aliases/npm.zsh | 20 | ||||
| -rw-r--r-- | external/zsh/aliases/system.zsh | 13 | ||||
| -rw-r--r-- | external/zsh/aliases/xplt.zsh | 55 |
8 files changed, 248 insertions, 0 deletions
diff --git a/external/zsh/aliases/dev.zsh b/external/zsh/aliases/dev.zsh new file mode 100644 index 0000000..c02eb20 --- /dev/null +++ b/external/zsh/aliases/dev.zsh @@ -0,0 +1,24 @@ + +alias aws="docker run --rm -it amazon/aws-cli" + +# :: Filename Pattern Replacetext +far() { + local file_r="$1"; shift; + local matcher_r="$1"; shift; + local result="$1"; shift; + fd "$file_r" | sad "$matcher_r" "$result" -p diff-so-fancy "$@"; +} + +# :: FileType Filename +codi() { + local syntax="${1:-python}" + shift + nvim -c \ + "let g:startify_disable_at_vimenter = 1 |\ + set bt=nofile ls=0 |\ + hi ColorColumn ctermbg=NONE |\ + hi VertSplit ctermbg=NONE |\ + hi NonText ctermfg=0 |\ + Codi $syntax" "$@" +} + diff --git a/external/zsh/aliases/dir.zsh b/external/zsh/aliases/dir.zsh new file mode 100644 index 0000000..508634e --- /dev/null +++ b/external/zsh/aliases/dir.zsh @@ -0,0 +1,27 @@ +take() { mkdir -p $@ && cd ${@:$#}; } + +alias ..='cd ..'; +alias ...='cd ../..'; + +alias gdv='cd ~/dev/'; + +alias gpic='cd ~/Pictures'; +alias gdl='cd ~/Downloads/dl'; +alias gm='cd ~/Downloads/music'; + +alias gnotes='cd ~/.config/vimwiki'; +alias gqute='cd ~/.config/qutebrowser'; + +alias gvim='cd ~/.config/nvim'; +alias gcmd='cd ~/scripts/commands'; +alias gzsh='cd ~/.config/zshconf'; + +alias gsuck='cd ~/.config/suckless'; +alias gdwm='cd ~/.config/suckless/dwm'; +alias gbar='cd ~/.config/suckless/dwmblocks'; + +alias gkey='cd ~/.config/suckless/shotkey'; + +alias gmutt='cd ~/.config/neomutt'; +alias gmuttp='cd ~/.work-config/neomutt'; + diff --git a/external/zsh/aliases/edit.zsh b/external/zsh/aliases/edit.zsh new file mode 100644 index 0000000..fa5e1b6 --- /dev/null +++ b/external/zsh/aliases/edit.zsh @@ -0,0 +1,17 @@ +# Config editors +alias eorg='gnotes && sensible-editor index.md'; +alias ezsh='gzsh && sensible-editor ~/.zshrc'; +alias edot='sensible-editor ~/scripts/dotfiles.sh'; +alias evim='gvim && sensible-editor init.lua'; + +alias edwm='gdwm && sensible-editor config.def.h'; +alias ebar='gbar && sensible-editor blocks.h'; +alias ekey='gkey && sensible-editor config.h'; +alias equte='gqute && sensible-editor config.py'; +alias eas='sensible-editor ~/.config/autostart.sh'; +alias emime="sensible-editor ~/.bin/open"; + +alias ehosts='sudo nvim /etc/hosts'; + +alias emutt='gmuttp && sensible-editor ~/.config/neomutt/neomuttrc'; + diff --git a/external/zsh/aliases/git.zsh b/external/zsh/aliases/git.zsh new file mode 100644 index 0000000..47d8c0c --- /dev/null +++ b/external/zsh/aliases/git.zsh @@ -0,0 +1,70 @@ +#function git_current_branch() { + #local ref + #ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) + #local ret=$? + #if [[ $ret != 0 ]]; then + #[[ $ret == 128 ]] && return # no git repo. + #ref=$(command git rev-parse --short HEAD 2> /dev/null) || return + #fi + #echo ${ref#refs/heads/} +#} + +# reset-origin a2_develop +reset-origin() { + if [[ -z $(git status -s) ]]; + then + currentBranch="$(git rev-parse --abbrev-ref HEAD)"; + branch="$1"; + git checkout $branch && + git pull && + git reset --hard origin/production && + git push -u origin $branch -f && + git checkout $currentBranch; + else + echo "Your branch is dirty. Stash or commit changed before proceeding"; + fi +} + +# Git aliases +alias g='git' + +alias ga='git add' +alias gaa='git add --all' + +alias gco='git checkout' +alias gb='git branch' + +alias gc='git commit -v' +alias gcm='git commit -v -m' +alias gc!='git commit -v --amend' + +alias gst='git status' +alias gd='git diff' +alias gl='git log' + +alias gp='git push' + +grename() { + if [[ -z "$1" || -z "$2" ]]; then + echo "Usage: $0 old_branch new_branch" + return 1 + fi + + # Rename branch locally + git branch -m "$1" "$2" + # Rename branch in origin remote + if git push origin :"$1"; then + git push --set-upstream origin "$2" + fi +} + +g_most_edited() { + git log --pretty=format: --name-only "$@" | \ + sort | \ + uniq -c | \ + sort -rg | \ + grep -E -v '.(html|scss|json)$' | \ + head -n 10 \ + ; +} + diff --git a/external/zsh/aliases/ls.zsh b/external/zsh/aliases/ls.zsh new file mode 100644 index 0000000..b199563 --- /dev/null +++ b/external/zsh/aliases/ls.zsh @@ -0,0 +1,22 @@ +# Trash +alias trash="ls \$TRASH_TMP_DIR"; + +# List files aliases +alias ls="lsd"; +alias l="ls -1"; +alias la='ls -a'; +alias ll='ls -alF'; +alias lt='ls --tree'; +alias la='ls -A'; +alias lsize='du -h -d1'; + +lc () { # lf with cd to navigated directory on quit + tmp="$(mktemp)" + lf -last-dir-path="$tmp" "$@" + if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + rm -f "$tmp" + [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir" + fi +} + diff --git a/external/zsh/aliases/npm.zsh b/external/zsh/aliases/npm.zsh new file mode 100644 index 0000000..efc8ec7 --- /dev/null +++ b/external/zsh/aliases/npm.zsh @@ -0,0 +1,20 @@ + +# Node aliases +alias nr="npm run"; +alias ns="npm start"; +alias nt="npm test"; + +run_npm_script() { + [[ ! -f "package.json" ]] && return 1; + + local commands=$(node -e 'const pkg = require("./package.json"); Object.entries(pkg.scripts || {}).map(([key, value]) => console.log(`${key}\t\t "${value}"`))'); + + local result=$(echo -e "$commands" | fzf | cut -f1); + + [[ -z "$result" ]] && return 1; + yarn "$result"; +} + +zle -N run_npm_script; +bindkey '^B' run_npm_script; + diff --git a/external/zsh/aliases/system.zsh b/external/zsh/aliases/system.zsh new file mode 100644 index 0000000..48951a9 --- /dev/null +++ b/external/zsh/aliases/system.zsh @@ -0,0 +1,13 @@ + +# Pacman aliases +alias auto-remove="yay -Rcs \$(yay -Qdtq)"; +alias update="yay -Syu"; +alias mirrorlist-refresh="sudo reflector --latest 200 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist-arch" + +# Sandbox +alias sandbox="sudo ~/scripts/host-file-elb-update.sh"; + +# Runit helpers +sv_enable() { [[ -f "/etc/runit/sv/$1" ]] && sudo ln -s /etc/runit/sv/$1 /run/runit/service; } +sv_disable() { sudo unlink /run/runit/service/$1; } + diff --git a/external/zsh/aliases/xplt.zsh b/external/zsh/aliases/xplt.zsh new file mode 100644 index 0000000..e2df43d --- /dev/null +++ b/external/zsh/aliases/xplt.zsh @@ -0,0 +1,55 @@ +export WORDLISTS=~/dev/xploits/wordlist; +export ROCK_YOU_WORDS="$WORDLISTS/rockyou.txt"; +export URL_WORDS="$WORDLISTS/dirb/common.txt"; +export URL_WORDS_MED="$WORDLISTS/dirb/dirbuster/directory-list-lowercase-2.3-medium.txt"; + +# metasploit +alias msfc="msfconsole --quiet -x \"db_connect postgres@msf\"" +# exploitdb +alias ssplt="searchsploit" +alias sspx="searchsploit -x" + +# Port scan +alias rmap="docker run -it --rm --name rustscan rustscan/rustscan:1.10.0" + +# DVWA +alias dvwa="docker run --rm -it -p 80:80 vulnerables/web-dvwa" + +# Directory search +alias crawl="gobuster dir -w $URL_WORDS" +alias crawl_strict="gobuster dir -w $URL_WORDS_MED" + +new_room() { + take ~/dev/xploits/temp/$1; nvim README.md; +} + +jrock() { + [[ "$#" != "2" ]] && echo "jrock (format) (hashfile)" && return 1; + john -format="$1" "$2" -wordlist=$ROCK_YOU_WORDS; +} + +hrock() { + # Usage: hrock $mode $hashfile + # mode - (1800 for sha512crypt $6$) + [[ "$#" != "2" ]] && echo "hrock (mode-num) (hashfile)" && return 1; + hashcat -m "$1" "$2" -o ./out $ROCK_YOU_WORDS --force; +} + +hydra_ssh() { + # Usage: hydra_ssh $username $ip + [[ "$#" != "2" ]] && echo "hydru (username) (host)" && return 1; + hydra -l $1 -P $ROCK_YOU_WORDS ssh://$2 -V; +} +hydra_post() { + # Usage: hydra_post $username $ip $login-string + # /login:username=^USER^&password=^PASS^:incorrect + [[ "$#" != "2" ]] && echo "hydru (username) (host)" && return 1; + hydra -l $1 -P $ROCK_YOU_WORDS $2 http-post-form "$3" -V; +} + +ip_get() { + # Usage: ip_get [$ip] + curl https://json.geoiplookup.io/$1 | \ + jq '.ip + " | " + .asn + "(" + .district + ", " + .region + ")"'; +} + |
