From d7fc680abebace086cf10349732344df116d2c66 Mon Sep 17 00:00:00 2001 From: druckdev <63563978+druckdev@users.noreply.github.com> Date: Fri, 25 Sep 2020 01:26:17 +0200 Subject: [PATCH] zsh: Refactor functions Combine functions{Pre,Post}.zsh into functions.zsh. There is no reason or sense in splitting the functions like that and differentiating between functions that should be loaded before and after sourcing the aliases. Rename the functions from funcPre, making their aliases superfluous. --- .config/zsh/.zshrc | 3 +-- .config/zsh/plugins/alias.zsh | 4 ---- .../{functionsPost.zsh => functions.zsh} | 20 ++++++++++++++++++- .config/zsh/plugins/functionsPre.zsh | 20 ------------------- 4 files changed, 20 insertions(+), 27 deletions(-) rename .config/zsh/plugins/{functionsPost.zsh => functions.zsh} (96%) delete mode 100644 .config/zsh/plugins/functionsPre.zsh diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index f3389c7..16dbb21 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -130,9 +130,8 @@ if [ -e "$ZSH_CONF/stderred/build/libstderred.so" ]; then export STDERRED_ESC_CODE="$(tput bold && tput setaf 1)" export STDERRED_BLACKLIST="^(git|curl|wget|swipl)$" fi -comp-source "$ZSH_CONF/functionsPre.zsh" comp-source "$ZSH_CONF/alias.zsh" -comp-source "$ZSH_CONF/functionsPost.zsh" +comp-source "$ZSH_CONF/functions.zsh" comp-source "$ZSH_CONF/transfer.zsh" comp-source "$ZSH_CONF/zsh-autosuggestions/zsh-autosuggestions.zsh" comp-source "$ZSH_CONF/completion.zsh" diff --git a/.config/zsh/plugins/alias.zsh b/.config/zsh/plugins/alias.zsh index 97a6e88..6508f24 100644 --- a/.config/zsh/plugins/alias.zsh +++ b/.config/zsh/plugins/alias.zsh @@ -52,10 +52,6 @@ alias feh='feh -.' # 'Temporary' shell in alternate mode that does not mess with the scrollback history alias tmpshell='tput smcup && zsh && tput rmcup' -## functions -alias trash=_trash_list_default -alias nemo=_nemo_wd_default - ## git alias gs='git status --short' # overrides ghostscript alias gits='gs' diff --git a/.config/zsh/plugins/functionsPost.zsh b/.config/zsh/plugins/functions.zsh similarity index 96% rename from .config/zsh/plugins/functionsPost.zsh rename to .config/zsh/plugins/functions.zsh index d1e2d47..c1683ba 100644 --- a/.config/zsh/plugins/functionsPost.zsh +++ b/.config/zsh/plugins/functions.zsh @@ -1,5 +1,5 @@ ## Author: druckdev -## Created: 2019-10-27 (originally 2019-08-28 as functions.zsh) +## Created: 2019-08-28 ## change into dir and print accordingly function cl() { @@ -328,3 +328,21 @@ safe-remove() { fi udisksctl power-off -b "/dev/$(lsblk -no pkname "$1")" } + +## List items in trash if no argument is specified +function trash() { + if (( ! $# )); then + command trash-list + else + command trash "$@" + fi +} + +## Open nemo in current directory if no argument is specified +function nemo() { + if (( ! $# )); then + command nemo . + else + command nemo "$@" + fi +} diff --git a/.config/zsh/plugins/functionsPre.zsh b/.config/zsh/plugins/functionsPre.zsh deleted file mode 100644 index 1a890af..0000000 --- a/.config/zsh/plugins/functionsPre.zsh +++ /dev/null @@ -1,20 +0,0 @@ -## Author: druckdev -## Created: 2019-10-27 (originally 2019-08-28 as functions.zsh) - -## List items in trash if no argument is specified -function _trash_list_default() { - if [ $# -eq 0 ]; then - command trash-list - else - command trash "$@" - fi -} - -## Open nemo in current directory if no argument is specified -function _nemo_wd_default() { - if [ $# -eq 0 ]; then - command nemo ./ - else - command nemo "$@" - fi -}