From 47919f9a9beaf575a1e3b9d7c02cc8ff3324c0ac Mon Sep 17 00:00:00 2001 From: Nathaniel Young Date: Mon, 28 Oct 2024 21:57:57 -0700 Subject: [PATCH] removes zsh successful cmd filter and uses zsh plugin instead --- Dockerfile | 2 -- configs/nathaniel/config.toml | 2 ++ functions/zsh_successful_cmd_filter/README.md | 18 ------------------ .../zsh_successful_cmd_filter/config.toml | 1 - functions/zsh_successful_cmd_filter/install.sh | 7 ------- templates/zshrc_successful_cmd_hist.zsh | 18 ------------------ 6 files changed, 2 insertions(+), 46 deletions(-) delete mode 100644 functions/zsh_successful_cmd_filter/README.md delete mode 100644 functions/zsh_successful_cmd_filter/config.toml delete mode 100755 functions/zsh_successful_cmd_filter/install.sh delete mode 100644 templates/zshrc_successful_cmd_hist.zsh diff --git a/Dockerfile b/Dockerfile index c78fc39..0582c16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,6 @@ RUN if [ "$MIN" = "no" ]; then \ sed -i '1 e cat /tmp/templates/zshrc_disable_flag.zsh' ~/.zshrc; \ fi && \ echo "" >> ~/.zshrc && \ - cat /tmp/templates/zshrc_successful_cmd_hist.zsh >> ~/.zshrc && \ - echo "" >> ~/.zshrc && \ cat /tmp/templates/gitpod_exports.zsh >> ~/.zshrc && \ echo 'for i in $(ls $HOME/.bashrc.d/ | grep -v python); do source $HOME/.bashrc.d/$i > /dev/null 2>&1; done' >> ~/.zshrc && \ echo "" >> ~/.zshrc && \ diff --git a/configs/nathaniel/config.toml b/configs/nathaniel/config.toml index 6546e24..a53f3b8 100644 --- a/configs/nathaniel/config.toml +++ b/configs/nathaniel/config.toml @@ -158,6 +158,7 @@ tags = [ "terminal" ] [ install_ohmyzsh_plugins ] tags = [ "terminal" ] options = [ + "https://github.com/nyoungstudios/zsh-history-on-success", "https://github.com/zsh-users/zsh-autosuggestions", "https://github.com/zsh-users/zsh-syntax-highlighting" ] @@ -170,6 +171,7 @@ options = [ "copyfile", "sudo", "zsh-autosuggestions", + "zsh-history-on-success", "zsh-syntax-highlighting" ] diff --git a/functions/zsh_successful_cmd_filter/README.md b/functions/zsh_successful_cmd_filter/README.md deleted file mode 100644 index 45f0301..0000000 --- a/functions/zsh_successful_cmd_filter/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Zsh Successful Cmd Filter - -Configuration for a `zsh_successful_cmd_filter` entry. - -## Description - -Appends a couple functions to your `.zshrc` file to only add successfully run command to your `.zsh_history` file by looking at its exit code. Also, saves multi-line commands as single-line commands in your history. - -## Options - -Accepts exactly 0 arguments - -## Example - -```toml -[ zsh_successful_cmd_filter ] -options = [] -``` diff --git a/functions/zsh_successful_cmd_filter/config.toml b/functions/zsh_successful_cmd_filter/config.toml deleted file mode 100644 index cd35535..0000000 --- a/functions/zsh_successful_cmd_filter/config.toml +++ /dev/null @@ -1 +0,0 @@ -install_function = "install_zsh_successful_cmd_filter" diff --git a/functions/zsh_successful_cmd_filter/install.sh b/functions/zsh_successful_cmd_filter/install.sh deleted file mode 100755 index be5e841..0000000 --- a/functions/zsh_successful_cmd_filter/install.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -install_zsh_successful_cmd_filter() { - # appends zshaddhistory and precmd hooks - echo "" >> ~/.zshrc - cat templates/zshrc_successful_cmd_hist.zsh >> ~/.zshrc -} diff --git a/templates/zshrc_successful_cmd_hist.zsh b/templates/zshrc_successful_cmd_hist.zsh deleted file mode 100644 index fb1bfcc..0000000 --- a/templates/zshrc_successful_cmd_hist.zsh +++ /dev/null @@ -1,18 +0,0 @@ -# credits: https://scarff.id.au/blog/2019/zsh-history-conditional-on-command-success/ -function zshaddhistory() { - # Remove line continuations since otherwise a "\" will eventually - # get written to history with no newline. - LASTHIST=${1//\\$'\n'/} - # Return value 2: "... the history line will be saved on the internal - # history list, but not written to the history file". - return 2 -} - -# zsh hook called before the prompt is printed. See man zshmisc(1). -function precmd() { - # Write the last command if successful and if the last command is not whitespace characters, - # using the history buffered by zshaddhistory(). - if [[ $? == 0 && -n ${LASTHIST//[[:space:]\n]/} && -n $HISTFILE ]] ; then - print -sr -- ${=${LASTHIST%%'\n'}} - fi -}