From a0c2da6d70c998511a1c480476d88487a01d0e96 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 20 Dec 2021 19:57:39 +0000 Subject: [PATCH] Inline zshrc It really doesn't need to be multiple files. And it's easier to manage this way --- files/zshrc | 145 ++++++++++++++++++++++++++++++++++++ files/zshrc/.zshrc | 34 --------- files/zshrc/applications.sh | 50 ------------- files/zshrc/base.sh | 22 ------ files/zshrc/crab.sh | 5 -- files/zshrc/environment.sh | 7 -- files/zshrc/javascript.sh | 32 -------- tasks/shell.yml | 2 +- 8 files changed, 146 insertions(+), 151 deletions(-) create mode 100644 files/zshrc delete mode 100644 files/zshrc/.zshrc delete mode 100644 files/zshrc/applications.sh delete mode 100644 files/zshrc/base.sh delete mode 100644 files/zshrc/crab.sh delete mode 100644 files/zshrc/environment.sh delete mode 100644 files/zshrc/javascript.sh diff --git a/files/zshrc b/files/zshrc new file mode 100644 index 0000000..3028b2b --- /dev/null +++ b/files/zshrc @@ -0,0 +1,145 @@ +# Path to oh-my-zsh installation. +export ZSH=/usr/share/oh-my-zsh/ + +# Plugins +plugins=( + django + pip + python + common-aliases + extract + heroku +) + +export COMPLETION_WAITING_DOTS="true" + +# Enable oh-my-zsh +source $ZSH/oh-my-zsh.sh + +source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +export fpath=(/usr/share/zsh/site-functions $fpath) + +autoload -U compinit && rm -f ~/.zcompdump && compinit +autoload -Uz colors && colors + +local ret_status="%(?:%{$fg_bold[green]%}λ :%{$fg_bold[red]%}λ )" +export PROMPT="${ret_status} %{$fg_bold[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%~%{$reset_color%}$ " + +alias src="source {{ home }}/.zshrc && tmux source {{ home }}/.tmux.conf" + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# Set environment variables +export DOTFILES=${HOME}/.dotfiles + +export TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S' +export HISTCONTROL=ignoreboth + +export BROWSER=$(which firefox) +export EDITOR=$(which nvim) + + +# bash aliases +alias refresh="cd $PWD > /dev/null" +alias c="clear" +alias e="exit" +alias no="yes n" +alias open="mimeopen" +alias browse "mimeopen ." + +# colourify things! +alias ls='ls --color=auto' +alias grep='grep --color=auto' + +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$//'\'')"' + +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + + +# Node stuff +alias ni="npm install" +alias ns="npm start" +alias nt="npm test" + +nb() { + if [ $# -eq 0 ]; then + command npm run build + else + for arg in "$@" + do + command npm run build-${arg} + done + fi +} + +nr() { + for arg in "$@" + do + command npm run $arg + done +} + +nvm() { # This takes ~1sec, so we lazy-load it. + unset $0 + source "/usr/share/nvm/init-nvm.sh" + $0 $@ +} + +npx () { + command $(npm bin)/$@ +} + +eval $(thefuck --alias) +eval "$(pazi init zsh)" + +# git aliases +alias gs="git status" +alias gd="git diff" +alias git-root='cd $(git root)' + +hub() { + if [ $# -eq 1 ]; then + command git clone git@github.com:RealOrangeOne/${1} --recursive && cd ${1} + else + command git clone git@github.com:${1}/${2} --recursive && cd ${2} + fi +} + +git-cleanup() { + command git checkout master + command git branch --merged | grep -v '*' | xargs -n 1 git branch -D + command git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D + command git remote prune origin + command git checkout - +} + +alias t="tig" +alias ts="tig status" + + +# Gnome +gd-lock() { + sessionid=`loginctl list-sessions | grep $USER | awk '{print $1}'` + loginctl lock-session $sessionid +} +gd-unlock() { + sessionid=`loginctl list-sessions | grep $USER | awk '{print $1}'` + loginctl unlock-session $sessionid +} + +# miscellaneous software aliases +alias serve="/usr/bin/python3 -m http.server" +alias regen-ssh-conf="assh config build > ~/.ssh/config" +alias clip="xclip -selection clipboard" +alias cl="climate" +alias tmux-cleanup="tmux list-sessions | grep -v attached | cut -d: -f1 | xargs -t -n1 tmux kill-session -t" +alias lock-screen="xdotool key 'Super_L+l'" +alias mux="tmuxinator start" + +alias open-port="firewall-cmd --zone=public --add-port" +alias close-port="firewall-cmd --zone=public --remove-port" +alias reset-ports="firewall-cmd --complete-reload" diff --git a/files/zshrc/.zshrc b/files/zshrc/.zshrc deleted file mode 100644 index bf9e645..0000000 --- a/files/zshrc/.zshrc +++ /dev/null @@ -1,34 +0,0 @@ -# Path to oh-my-zsh installation. -export ZSH=/usr/share/oh-my-zsh/ - -# Plugins -plugins=( - django - pip - python - common-aliases - extract - heroku -) - -export COMPLETION_WAITING_DOTS="true" - -# Enable oh-my-zsh -source $ZSH/oh-my-zsh.sh - -source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -export fpath=(/usr/share/zsh/site-functions $fpath) - -autoload -U compinit && rm -f ~/.zcompdump && compinit -autoload -Uz colors && colors - -local ret_status="%(?:%{$fg_bold[green]%}λ :%{$fg_bold[red]%}λ )" -export PROMPT="${ret_status} %{$fg_bold[green]%}%n@%m%{$reset_color%}:%{$fg_bold[blue]%}%~%{$reset_color%}$ " - -alias src="source {{ home }}/.zshrc && tmux source {{ home }}/.tmux.conf" - -{% include "base.sh" %} -{% include "environment.sh" %} -{% include "applications.sh" %} -{% include "crab.sh" %} -{% include "javascript.sh" %} diff --git a/files/zshrc/applications.sh b/files/zshrc/applications.sh deleted file mode 100644 index bf88eac..0000000 --- a/files/zshrc/applications.sh +++ /dev/null @@ -1,50 +0,0 @@ -eval $(thefuck --alias) -eval "$(pazi init zsh)" - -# git aliases -alias gs="git status" -alias gd="git diff" -alias git-root='cd $(git root)' - -hub() { - if [ $# -eq 1 ]; then - command git clone git@github.com:RealOrangeOne/${1} --recursive && cd ${1} - else - command git clone git@github.com:${1}/${2} --recursive && cd ${2} - fi -} - -git-cleanup() { - command git checkout master - command git branch --merged | grep -v '*' | xargs -n 1 git branch -D - command git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D - command git remote prune origin - command git checkout - -} - -alias t="tig" -alias ts="tig status" - - -# Gnome -gd-lock() { - sessionid=`loginctl list-sessions | grep $USER | awk '{print $1}'` - loginctl lock-session $sessionid -} -gd-unlock() { - sessionid=`loginctl list-sessions | grep $USER | awk '{print $1}'` - loginctl unlock-session $sessionid -} - -# miscellaneous software aliases -alias serve="/usr/bin/python3 -m http.server" -alias regen-ssh-conf="assh config build > ~/.ssh/config" -alias clip="xclip -selection clipboard" -alias cl="climate" -alias tmux-cleanup="tmux list-sessions | grep -v attached | cut -d: -f1 | xargs -t -n1 tmux kill-session -t" -alias lock-screen="xdotool key 'Super_L+l'" -alias mux="tmuxinator start" - -alias open-port="firewall-cmd --zone=public --add-port" -alias close-port="firewall-cmd --zone=public --remove-port" -alias reset-ports="firewall-cmd --complete-reload" diff --git a/files/zshrc/base.sh b/files/zshrc/base.sh deleted file mode 100644 index 3dbf6db..0000000 --- a/files/zshrc/base.sh +++ /dev/null @@ -1,22 +0,0 @@ -# If not running interactively, don't do anything -case $- in - *i*) ;; - *) return;; -esac - - -# bash aliases -alias refresh="cd $PWD > /dev/null" -alias c="clear" -alias e="exit" -alias no="yes n" -alias open="mimeopen" -alias browse "mimeopen ." - -# colourify things! -alias ls='ls --color=auto' -alias grep='grep --color=auto' - -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$//'\'')"' - -[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" diff --git a/files/zshrc/crab.sh b/files/zshrc/crab.sh deleted file mode 100644 index 29c9755..0000000 --- a/files/zshrc/crab.sh +++ /dev/null @@ -1,5 +0,0 @@ -alias ctpt="NO_MIGRATIONS=true IN_TEST=true FILE_STORAGE='django.core.files.storage.FileSystemStorage' crab manage.py test $@ --keepdb" - -export ENV_FILE=etc/environments/development/env,.env -export PROC_FILE=etc/environments/development/procfile -export BIN_DIRS=env/bin diff --git a/files/zshrc/environment.sh b/files/zshrc/environment.sh deleted file mode 100644 index b3727d2..0000000 --- a/files/zshrc/environment.sh +++ /dev/null @@ -1,7 +0,0 @@ -export DOTFILES=${HOME}/.dotfiles - -export TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S' -export HISTCONTROL=ignoreboth - -export BROWSER=$(which firefox) -export EDITOR=$(which nvim) diff --git a/files/zshrc/javascript.sh b/files/zshrc/javascript.sh deleted file mode 100644 index 208e569..0000000 --- a/files/zshrc/javascript.sh +++ /dev/null @@ -1,32 +0,0 @@ -# npm aliases -alias ni="npm install" -alias ns="npm start" -alias nt="npm test" - -nb() { - if [ $# -eq 0 ]; then - command npm run build - else - for arg in "$@" - do - command npm run build-${arg} - done - fi -} - -nr() { - for arg in "$@" - do - command npm run $arg - done -} - -nvm() { # This takes ~1sec, so we lazy-load it. - unset $0 - source "/usr/share/nvm/init-nvm.sh" - $0 $@ -} - -npx () { - command $(npm bin)/$@ -} diff --git a/tasks/shell.yml b/tasks/shell.yml index 07e2387..d687d5b 100644 --- a/tasks/shell.yml +++ b/tasks/shell.yml @@ -44,7 +44,7 @@ - name: Install ZSH config template: - src: ./files/zshrc/.zshrc + src: ./files/zshrc dest: "{{ home }}/.zshrc" mode: 0644 owner: "{{ user }}"