Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Mac OSX Terminal – Clear Oh My ZSH History

Posted on April 9, 2018 By David Kittell

If you have fallen in love with Oh My Zsh you likely have at one point realized it currently lacks the “history -c” option to clear your terminal history.

This code below will help with that.

#!/bin/sh

#  Clear_OhMyZsh_History.sh
#
#  Script to remove all history or select content
#
#  Created by David Kittell on 8/26/16.
#

file=~/.zsh_history

function KillApp
{
  appname=$1
  ps -ax | grep $appname | sed 's/^[ \t]*//' | cut -d " " -f1 | while read -r pid cmd ; do
    echo "Killing $pid"
    kill $pid
  done
}

if [ -e "$file" ]; then
  echo "File exists"
  echo "Clearing all history"
  rm -f $file && KillApp Term
else
  echo "File does not exist"
fi
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Mac OS X Shell Mac OSX UNIX UNIX Shell Scripts

Post navigation

Previous post
Next post

Related Posts

UNIX – List USB Devices With lsusb

Posted on February 12, 2018February 12, 2018

On the Mac “lsusb -v” is rather clean in comparison to other systems. # If not already installed… # brew update && brew tap jlhonora/lsusb && brew install lsusb lsusb -v lsusb -v # or lsusb -v | grep -E ‘\<(Bus|iProduct|bDeviceClass|bDeviceProtocol|idVendor|idProduct|iManufacturer)’ 2>/dev/null All information on this site is shared with…

Read More

Format Zip Code Properly

Posted on November 11, 2013October 26, 2015

Sometimes a zip code is presented in a database with all nine numbers in the same column that has only five numbers. This query below will assist in formatting the numbers properly. SELECT CASE WHEN len(zip) = 10 AND substring(zip, 6, 1) = ‘-‘ THEN zip WHEN len(zip) = 5…

Read More

Ektron Content Status Codes

Posted on September 10, 2013October 26, 2015

This is a list of code definitions for the content_status column in the content table SELECT content_status ,count(content_status) FROM content GROUP BY content_status Letter Meaning Content state More Information A Approved Through the workflow and published on the Web site. Approved Content O Checked Out Currently being edited. Has not…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes