aboutsummaryrefslogtreecommitdiff
path: root/external/zsh
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-12-20 16:49:47 +0530
committerAkshay Nair <phenax5@gmail.com>2020-12-20 16:49:47 +0530
commit568f7903ca7464f99df659b8488bd731e4f2c4f0 (patch)
treedfa7f9d077eb85ec840c8bfcaa04c1d64cc5aa29 /external/zsh
parentc580a9ec2a1a43a682117eca41c3867e8771117a (diff)
downloadnixos-config-568f7903ca7464f99df659b8488bd731e4f2c4f0.tar.gz
nixos-config-568f7903ca7464f99df659b8488bd731e4f2c4f0.zip
Adds zsh config
Diffstat (limited to 'external/zsh')
-rw-r--r--external/zsh/aliases.zsh34
-rw-r--r--external/zsh/aliases/dev.zsh24
-rw-r--r--external/zsh/aliases/dir.zsh27
-rw-r--r--external/zsh/aliases/edit.zsh17
-rw-r--r--external/zsh/aliases/git.zsh70
-rw-r--r--external/zsh/aliases/ls.zsh22
-rw-r--r--external/zsh/aliases/npm.zsh20
-rw-r--r--external/zsh/aliases/system.zsh13
-rw-r--r--external/zsh/aliases/xplt.zsh55
-rw-r--r--external/zsh/config.zsh14
-rw-r--r--external/zsh/init.zsh11
-rw-r--r--external/zsh/keys.zsh51
-rw-r--r--external/zsh/paths.zsh42
-rw-r--r--external/zsh/plugins.zsh1
-rw-r--r--external/zsh/plugins/completion.zsh11
-rw-r--r--external/zsh/plugins/fzf-history.zsh19
-rw-r--r--external/zsh/plugins/magic-enter.zsh29
-rw-r--r--external/zsh/plugins/manpage.zsh6
-rw-r--r--external/zsh/plugins/sudo.zsh35
-rw-r--r--external/zsh/script-runners.zsh18
-rw-r--r--external/zsh/theme.zsh54
-rw-r--r--external/zsh/zshrc23
22 files changed, 596 insertions, 0 deletions
diff --git a/external/zsh/aliases.zsh b/external/zsh/aliases.zsh
new file mode 100644
index 0000000..7fb9112
--- /dev/null
+++ b/external/zsh/aliases.zsh
@@ -0,0 +1,34 @@
+
+for f in $ZSH_CUSTOM_CONF_FILES/aliases/*.zsh; do source $f; done;
+
+alias grep="grep --color=auto";
+
+# Application shortcuts
+alias e="sensible-editor";
+alias v="nvim";
+alias o='open $(fzf)';
+
+# Load work aliases
+# source "$HOME/.work-config/zshconf/aliases.zsh";
+
+# Utility stuff
+alias clock="tty-clock -t -b -c";
+alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"';
+alias show-mobile-screen="adb shell screenrecord --output-format=h264 - | ffplay -";
+
+# QR file transfer
+alias qr-send="qrcp";
+alias qr-get="qrcp receive";
+qr-str() { curl qrenco.de/$1; }
+
+# Audio download
+alias dl-audio="youtube-dl --ignore-errors --output '%(title)s.%(ext)s' --extract-audio";
+
+# Swallow window
+alias smpv="swallow mpv";
+alias ssxiv="swallow sxiv";
+alias szathura="swallow zathura";
+
+# Dictionary
+dict() { curl dict://dict.org/d:$1; }
+
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 + ")"';
+}
+
diff --git a/external/zsh/config.zsh b/external/zsh/config.zsh
new file mode 100644
index 0000000..eb409fa
--- /dev/null
+++ b/external/zsh/config.zsh
@@ -0,0 +1,14 @@
+export VISUAL='nvim'
+export EDITOR="nvim"
+export TERMINAL="st"
+export BROWSER="qutebrowser"
+export PRIVATE_BROWSER="$BROWSER ':open -p'";
+export READER="zathura"
+export FILE="lf"
+
+export FZF_DEFAULT_OPTS="--layout=reverse --height 40%"
+
+export HISTCONTROL=ignoreboth
+
+export LS_COLORS='di=35:ln=36:or=31:mi=31:ex=32:*.ts=36';
+
diff --git a/external/zsh/init.zsh b/external/zsh/init.zsh
new file mode 100644
index 0000000..1d7825c
--- /dev/null
+++ b/external/zsh/init.zsh
@@ -0,0 +1,11 @@
+
+export TRASH_TMP_DIR=/tmp/.trash-cache;
+
+[[ ! -d "$TRASH_TMP_DIR" ]] && mkdir $TRASH_TMP_DIR;
+
+#export rmrf() {
+ #for var in "$@"; do
+ #mv $var $TRASH_TMP_DIR;
+ #done
+#}
+
diff --git a/external/zsh/keys.zsh b/external/zsh/keys.zsh
new file mode 100644
index 0000000..5ed993c
--- /dev/null
+++ b/external/zsh/keys.zsh
@@ -0,0 +1,51 @@
+if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
+ function zle-line-init() {
+ echoti smkx
+ }
+ function zle-line-finish() {
+ echoti rmkx
+ }
+ zle -N zle-line-init
+ zle -N zle-line-finish
+fi
+
+bindkey -e;
+
+autoload -z edit-command-line; zle -N edit-command-line;
+bindkey "^E" edit-command-line;
+
+bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
+bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
+
+# CHeck
+bindkey ' ' magic-space
+
+if [[ "${terminfo[kpp]}" != "" ]]; then
+ bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
+fi
+if [[ "${terminfo[knp]}" != "" ]]; then
+ bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
+fi
+
+bindkey '^?' backward-delete-char # [Backspace] - delete backward
+if [[ "${terminfo[kdch1]}" != "" ]]; then
+ bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
+else
+ bindkey "^[[3~" delete-char
+ bindkey "^[3;5~" delete-char
+ bindkey "\e[3~" delete-char
+fi
+
+# start typing + [Up-Arrow] - fuzzy find history forward
+if [[ "${terminfo[kcuu1]}" != "" ]]; then
+ autoload -U up-line-or-beginning-search
+ zle -N up-line-or-beginning-search
+ bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
+fi
+# start typing + [Down-Arrow] - fuzzy find history backward
+if [[ "${terminfo[kcud1]}" != "" ]]; then
+ autoload -U down-line-or-beginning-search
+ zle -N down-line-or-beginning-search
+ bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
+fi
+
diff --git a/external/zsh/paths.zsh b/external/zsh/paths.zsh
new file mode 100644
index 0000000..7f5b26b
--- /dev/null
+++ b/external/zsh/paths.zsh
@@ -0,0 +1,42 @@
+export XDG_CONFIG_HOME=$HOME/.config;
+export XDG_DATA_HOME=$HOME/.local/share;
+export PKG_CONFIG_PATH=/usr/lib/pkgconfig;
+
+# Local scripts
+export SCRIPTS_DIR="$HOME/scripts";
+export SCRIPTS_BINARY_DIR="$HOME/.bin";
+export COMMANDS_DIR="$HOME/scripts/commands";
+
+# Lang specific stuff
+export CARGO_HOME=$XDG_CONFIG_HOME/cargo;
+export GEM_HOME=$HOME/.gem;
+export GOROOT=/usr/lib/go;
+export GOPATH=$HOME/dev/go;
+export DENO_INSTALL="$HOME/.config/deno";
+
+# Path
+PATH=$GEM_HOME/ruby/2.7.0/bin:$GOPATH/bin:$GOROOT/bin:$CARGO_HOME/bin:$DENO_INSTALL/bin:$PATH;
+PATH="$HOME/.local/bin:$PATH"
+PATH="$SCRIPTS_BINARY_DIR:$PATH";
+PATH="$COMMANDS_DIR:$PATH";
+export PATH;
+
+# Android/JVM garbage TODO: Remove if not needed
+export ANDROID_HOME=$HOME/dump/android-sdk;
+PATH=$PATH:$HOME/.config/android-sdk/platform-tools;
+PATH=$HOME/dump/flutter/bin:$PATH;
+export PATH;
+
+
+# Util config
+export rofi_LIBS=/usr;
+export GNUPGHOME=$XDG_CONFIG_HOME/gnupg;
+export PASSWORD_STORE_DIR=$XDG_CONFIG_HOME/password-store;
+export BTPD_HOME=$XDG_CONFIG_HOME/btpd;
+
+# Development dir variables
+export DEV_DIR="$HOME/dev";
+export PROJECTS_DIR="$DEV_DIR/projects";
+export SHAADI=$PROJECTS_DIR/sh-react;
+export REG_SHAADI=$PROJECTS_DIR/sh-profile-creation;
+
diff --git a/external/zsh/plugins.zsh b/external/zsh/plugins.zsh
new file mode 100644
index 0000000..0ab6100
--- /dev/null
+++ b/external/zsh/plugins.zsh
@@ -0,0 +1 @@
+for f in $ZSH_CUSTOM_CONF_FILES/plugins/*.zsh; do source $f; done;
diff --git a/external/zsh/plugins/completion.zsh b/external/zsh/plugins/completion.zsh
new file mode 100644
index 0000000..bf6e731
--- /dev/null
+++ b/external/zsh/plugins/completion.zsh
@@ -0,0 +1,11 @@
+
+autoload -Uz compinit && compinit;
+# load bashcompinit for some old bash completions
+autoload bashcompinit && bashcompinit
+
+# partial completion suggestions
+zstyle ':completion:*' list-suffixes
+zstyle ':completion:*' expand prefix suffix
+
+# Case insensitive
+zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
diff --git a/external/zsh/plugins/fzf-history.zsh b/external/zsh/plugins/fzf-history.zsh
new file mode 100644
index 0000000..f91cc99
--- /dev/null
+++ b/external/zsh/plugins/fzf-history.zsh
@@ -0,0 +1,19 @@
+full_history() {
+ [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1;
+}
+
+trim() { sed 's/^\s*//g'; }
+reverse() { sed -n '1!G;h;$p'; }
+unique() { awk '!seen[$0]++'; }
+
+search_history() {
+ local result=$(full_history | trim | cut -d' ' -f 2- | reverse | unique | fzf);
+
+ # Replace the buffer with the editor output.
+ print -Rz - "$(echo -n "$result" | trim)";
+
+ zle send-break # Force reload from the buffer stack
+}
+
+zle -N search_history;
+bindkey '^R' search_history;
diff --git a/external/zsh/plugins/magic-enter.zsh b/external/zsh/plugins/magic-enter.zsh
new file mode 100644
index 0000000..5d50316
--- /dev/null
+++ b/external/zsh/plugins/magic-enter.zsh
@@ -0,0 +1,29 @@
+# Bind quick stuff to enter!
+#
+# Pressing enter in a git directory runs `git status`
+# in other directories `ls`
+magic-enter () {
+ # If commands are not already set, use the defaults
+ [ -z "$MAGIC_ENTER_GIT_COMMAND" ] && MAGIC_ENTER_GIT_COMMAND="git status -u ."
+ [ -z "$MAGIC_ENTER_OTHER_COMMAND" ] && MAGIC_ENTER_OTHER_COMMAND="ls -lh ."
+
+ if [[ -z $BUFFER ]]; then
+ echo ""
+ if git rev-parse --is-inside-work-tree &>/dev/null; then
+ eval "$MAGIC_ENTER_GIT_COMMAND"
+ else
+ eval "$MAGIC_ENTER_OTHER_COMMAND"
+ fi
+ zle redisplay
+ else
+ zle accept-line
+ fi
+}
+
+zle -N magic-enter
+
+bindkey "^M" magic-enter
+
+# Auto correct typos
+#setopt CORRECT
+#setopt CORRECT_ALL
diff --git a/external/zsh/plugins/manpage.zsh b/external/zsh/plugins/manpage.zsh
new file mode 100644
index 0000000..8c8c372
--- /dev/null
+++ b/external/zsh/plugins/manpage.zsh
@@ -0,0 +1,6 @@
+
+open-man() { macho; }
+
+zle -N open-man
+bindkey -M emacs '^_' open-man
+
diff --git a/external/zsh/plugins/sudo.zsh b/external/zsh/plugins/sudo.zsh
new file mode 100644
index 0000000..fd43b93
--- /dev/null
+++ b/external/zsh/plugins/sudo.zsh
@@ -0,0 +1,35 @@
+# ------------------------------------------------------------------------------
+# Description
+# -----------
+#
+# sudo or sudoedit will be inserted before the command
+#
+# ------------------------------------------------------------------------------
+# Authors
+# -------
+#
+# * Dongweiming <ciici123@gmail.com>
+#
+# ------------------------------------------------------------------------------
+
+MAGIC_ENTER_GIT_COMMAND='git status';
+MAGIC_ENTER_OTHER_COMMAND='ls';
+
+sudo-command-line() {
+ [[ -z $BUFFER ]] && zle up-history
+ if [[ $BUFFER == sudo\ * ]]; then
+ LBUFFER="${LBUFFER#sudo }"
+ elif [[ $BUFFER == $EDITOR\ * ]]; then
+ LBUFFER="${LBUFFER#$EDITOR }"
+ LBUFFER="sudoedit $LBUFFER"
+ elif [[ $BUFFER == sudoedit\ * ]]; then
+ LBUFFER="${LBUFFER#sudoedit }"
+ LBUFFER="$EDITOR $LBUFFER"
+ else
+ LBUFFER="sudo $LBUFFER"
+ fi
+}
+
+zle -N sudo-command-line;
+bindkey '^Z' sudo-command-line;
+
diff --git a/external/zsh/script-runners.zsh b/external/zsh/script-runners.zsh
new file mode 100644
index 0000000..57cb8a7
--- /dev/null
+++ b/external/zsh/script-runners.zsh
@@ -0,0 +1,18 @@
+
+BIN_DIR="$SCRIPTS_BINARY_DIR";
+SCRIPT="$SCRIPTS_DIR";
+
+_create_runner() {
+ local name="$1";
+ local filename="${2:-"$1.sh"}";
+ local filepath="$SCRIPT/$filename";
+
+ alias $name="$filepath";
+}
+
+_create_runner "artemis";
+_create_runner "update-dotfiles" "dotfiles.sh";
+_create_runner "session-box" "qutebrowser/session-box.sh";
+
+scr() { ~/scripts/$@; }
+
diff --git a/external/zsh/theme.zsh b/external/zsh/theme.zsh
new file mode 100644
index 0000000..8666a7a
--- /dev/null
+++ b/external/zsh/theme.zsh
@@ -0,0 +1,54 @@
+setopt prompt_subst
+
+# Theme
+COL_ACCENT=13;
+
+COL_DIR=$COL_ACCENT;
+
+COL_STATUS_ERROR=red;
+COL_STATUS_BG=cyan;
+
+COL_GIT_DIRTY=yellow;
+COL_GIT_NORMAL=green;
+
+
+segment() { echo -n "%K{$2}%F{$3} $1 %f%k"; }
+git_changes() { git status --porcelain 2> /dev/null | wc -l; }
+
+# Prompt dir
+p_dir() {
+ segment "%2~" $COL_DIR white;
+}
+
+# Prompt terminal status
+p_status() {
+ echo -n "%(?..$(segment 'x' black $COL_STATUS_ERROR))"
+ echo -n "%(1j.$(segment '(jobs: %j)' black $COL_STATUS_BG).)"
+}
+
+p_git() {
+ local ref dirty mode repo_path color;
+
+ if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
+ repo_path=$(git rev-parse --git-dir 2>/dev/null);
+ ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)";
+
+ changes=$(git_changes);
+ color=$([[ ! $changes = "0" ]] && echo $COL_GIT_DIRTY || echo $COL_GIT_NORMAL);
+ dirty=$([[ ! $changes = "0" ]] && echo " ($changes)");
+
+ segment "${ref/refs\/heads\//}$dirty" $color black;
+ fi
+}
+
+prompt() {
+ RETVAL=$?;
+ p_status;
+ p_dir;
+ echo -n '$(p_git)';
+ segment "$" black white;
+}
+
+export PROMPT="$(prompt) ";
+#export RPROMPT='wow'
+
diff --git a/external/zsh/zshrc b/external/zsh/zshrc
new file mode 100644
index 0000000..114e68d
--- /dev/null
+++ b/external/zsh/zshrc
@@ -0,0 +1,23 @@
+autoload -U colors && colors;
+setopt auto_cd;
+setopt inc_append_history;
+
+export SAVEHIST=10000
+# export HISTSIZE=50000
+# export HISTFILE=~/.config/zsh_history
+
+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_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 share_history # share command history data
+
+export ZSH_CUSTOM_CONF_FILES="$HOME/nixos/external/zsh";
+
+for f in $ZSH_CUSTOM_CONF_FILES/*.zsh; do source $f; done;
+source $ZSH_CUSTOM_CONF_FILES/aliases.zsh;
+
+# Plugins
+# source ~/.config/zshplugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh;
+