From 3228cf2394792d8ba6a21cd43ab3aba8a3256e4a Mon Sep 17 00:00:00 2001 From: chawley Date: Sun, 18 Feb 2024 14:33:55 -0500 Subject: [PATCH] Updated .zshrc and removed aliases and functions --- .zsh_aliases | 79 ---------------------- .zsh_functions | 104 ----------------------------- .zshrc | 173 ++++++------------------------------------------- README.md | 5 +- 4 files changed, 23 insertions(+), 338 deletions(-) delete mode 100644 .zsh_aliases delete mode 100644 .zsh_functions diff --git a/.zsh_aliases b/.zsh_aliases deleted file mode 100644 index 952a986..0000000 --- a/.zsh_aliases +++ /dev/null @@ -1,79 +0,0 @@ -# Turn on interactive mode for dangerous commands -alias cp='cp -iv' -alias mv='mv -iv' -alias rm='rm -iv' - -# File sizes should always be human-readable -alias df='df -h' -alias du='du -h' - -# Greps -alias egrep='egrep --color=auto' # show differences in colour -alias fgrep='fgrep --color=auto' # show differences in colour -alias h='history | grep' - -# File Listing -alias l='ls -CF' # list with Columns -alias la='ls -CFA' # l with . and .. -alias ll='ls -l' # long list -alias lla='ls -al' # ll with . and .. -alias ls='ls -hF --color=tty' # classify files in colour -alias lls='ls -lh --sort=size --reverse' -alias llt='ls -l -t -r' - -# Extras -alias ping='ping -c 5' # Stop pinging after 5 pings -alias vi='vim' # use vim instead of vi -alias less='less -r' # repaint screen - -# type 'warp' once to set the PWD, -# CD to other dirs then type 'warp' again to warp back -alias warp='if [[ "$w" == "" ]]; then w="$(pwd)"; else cd "$w"; unset w; fi' - -# Misc Shit -alias LISTEN='netstat -pant | grep LISTEN' # a quicker way to see what services are listening -alias fuck='sudo $(history -p \!\!)' # runs the last command as sudo -alias ..='cd ..' -alias ...='cd ../..' -alias ....='cd ../../..' - -# between head and less -alias page="head -n $(stty size | awk '{print $1 -2}')" - -# Get Ext IP -alias extip='curl -s -4 icanhazip.com' - -alias usedips='nmap -v -sn -n 192.168.0.0/24 -oG - | grep Up' -alias openips='nmap -v -sn -n 192.168.0.0/24 -oG - | grep Down' - -# webthis - create asimple HTTP server in the current directory serving on port 8000 -alias webthis='python -m SimpleHTTPServer 8000' - -# For cheating at DCSS -alias crawlsave='if [[ -f crawlsave.tgz ]]; then rm -f crawlsave.tgz; fi && tar cvzf crawlsave.tgz .crawl && crawl-tiles' -alias crawlrestore='rm -rf ~/.crawl && tar xvf ~/crawlsave.tgz -C ~/ && crawl-tiles' - -# Memory Pigs (top 10) -alias mempigs='ps aux | awk '\''{print $6/1024 " MB\t\t" $11 " " $12}'\'' | sort -n | tail -10' - -# Always get a proper output name from youtube-dl -alias ytdl='youtube-dl -o "%(title)s.%(ext)s" ' -alias ytdlmp3='youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" ' - -# termbin shortcut -alias tb='nc bin.planethawleywood.com 9999' - -# Update FuzzyFinder (https://github.com/junegunn/fzf#upgrading-fzf) -alias fzfup='cd ~/.fzf && git pull && ./install' - -# Git (a few in case globals aren't defined) -alias git-st='git status' -alias git-lg='git log --color --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit' -alias git-remotes='git remote -v update' - -# Edit files with vim/fzf -alias vfz='vim "`fzf`"' - -# Mirror website with wget -# (https://www.guyrutenberg.com/2014/05/02/make-offline-mirror-of-a-site-using-wget/#comment-2237076) -alias wgetMirror="/usr/bin/wget -o wget.log -mkEpnp –wait=9 –user-agent='Mozilla/5.0 (compatible; Googlebot/2.1; +http://www. google.com/bot.html)' –no-check-certificate" diff --git a/.zsh_functions b/.zsh_functions deleted file mode 100644 index c45b4b7..0000000 --- a/.zsh_functions +++ /dev/null @@ -1,104 +0,0 @@ -# BASH Functions - -# Shell note pad -note () { - # if file doesn't exist, create it - if [[ ! -f $HOME/.notes ]]; then - touch "$HOME/.notes" - fi - - if ! (($#)); then - # no arguments, print file - cat "$HOME/.notes" - elif [[ "$1" == "-c" ]]; then - # clear file - echo -n "Clear notes file? [Y/N] " - read replace - if [ "${replace}" = "Y" ] || [ "${replace}" = "y" ]; then - echo "Emptying notes file..." - printf "%s" > "$HOME/.notes" - echo "Done." - else - echo "Notes file preserved." - fi - else - # add all arguments to file - echo -n $(date +"%F %T | ") >> "$HOME/.notes" - printf "%s\n" "$*" >> "$HOME/.notes" - fi -} - -# tar/gzip a directory -# I use this before 'rm -rf'ing a directory I think is useless -# if nothing breaks after a predetermined amount of time, then the tar file is safe to delete -tardir() { - #ensure $1 is a directory - if [ ! -d "${1}" ]; then - echo "$1 is not a directory. Aborting." - return 1 - fi - #strip trailing slash - target="${1%/}" - echo "Dir size: $(du -hs ${target})" - tar czf "${target}".tar.gz "${target}" - echo "Archive size: $(du -hs ${target}.tar.gz)" -} - -# Replacement for 'for i in $(ls); do du -hs $i; done' that handles spaces -function dudir() { - if ! (($#)); then - dir=$(pwd) - else - dir="${1}" - fi - # redefine $IFS - o=$IFS - IFS=$(echo -en "\n\b") - for i in $(ls "${dir}"); do - du -hs "${i}" - done - # reset $IFS - IFS=$o -} - -# HAHA! Weather in the terminal -weather() { - if [ $(command -v curl) ]; then - if ! (($#)); then - curl wttr.in/44113 - else - curl wttr.in/$1 - fi - else - echo "curl not installed. Aborting." - fi -} - -# Replaces "ps aux | grep " with "psaux ". Shorter to type, more informational and doesn't include the command itself in the output. -psaux () { pgrep -f "$@" | xargs ps -fp 2>/dev/null; } - -# mail a file -email() { -if ! (($#)); then - echo "USAGE: email {filename} {email-address}" - return 1 -else - efile=${1} - eaddr=${2} - echo "See Attached" | mail -s "File: ${efile}" -a ${efile} ${2} -fi -} - -# simpler find for quick searches -f() { - find . -iname "*${1}*" - } - -# git testmerge -testmerge() { - echo "git merge --no-commit --no-ff $1" - git merge --no-commit --no-ff $1 - echo "git diff --cached" - git diff --cached - echo "'git merge --abort' when done" -} diff --git a/.zshrc b/.zshrc index 4dc7f2e..4526c5d 100644 --- a/.zshrc +++ b/.zshrc @@ -1,164 +1,33 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH +# Exports +export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin/:$PATH +export ZSH="$HOME/.oh-my-zsh" -# Path to your oh-my-zsh installation. -export ZSH=$HOME/.oh-my-zsh - -# Set name of the theme to load. Optionally, if you set this to "random" -# it'll load a random theme each time that oh-my-zsh is loaded. -# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes -# ZSH_THEME="robbyrussell" -# ZSH_THEME="avit" -# ZSH_THEME="bureau" -ZSH_THEME=powerlevel10k/powerlevel10k - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. Case -# sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment the following line to disable bi-weekly auto-update checks. -# DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to change how often to auto-update (in days). -# export UPDATE_ZSH_DAYS=13 - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) -# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=( - git - zsh-syntax-highlighting - ) - -# User configuration -# --------------------------------------------------------------------------------------------------------------------- -# ==> Source External Configs -# +ZSH_THEME="powerlevel10k/powerlevel10k" +POWERLEVEL9K_MODE="nerdfont-complete" +plugins=(git zsh-autosuggestions zsh-syntax-highlighting) +export ZSH_COMPDUMP=$ZSH/cache/completions/.zcompdump-$HOST source $ZSH/oh-my-zsh.sh -source $HOME/.zsh_aliases -source $HOME/.zsh_functions -# If there is a .zsh_local file, source it -[ -f ~/.zsh_local ] && source ~/.zsh_local +# User-defined Aliases and Functions +[[ ! -f ~/.shell_functions ]] || source ~/.shell_functions +[[ ! -f ~/.shell_aliases ]] || source ~/.shell_aliases -# --------------------------------------------------------------------------------------------------------------------- -# ==> History -# -HISTFILE=$HOME/.zsh_history -HISTSIZE=50000 -SAVEHIST=50000 +fortune -a | cowsay | lolcat -setopt EXTENDED_HISTORY -setopt HIST_VERIFY -setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. -setopt HIST_IGNORE_DUPS # Dont record an entry that was just recorded again. -setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. -setopt HIST_FIND_NO_DUPS # Do not display a line previously found. -setopt HIST_IGNORE_SPACE # Dont record an entry starting with a space. -setopt HIST_SAVE_NO_DUPS # Dont write duplicate entries in the history file. - -setopt inc_append_history -setopt share_history - -# --------------------------------------------------------------------------------------------------------------------- -# ==> KEY BINDINGS - from https://dougblack.io/words/zsh-vi-mode.html -# Commented out on 2021-02-09 in favor of learning emacs bindings -# -#bindkey -v -#bindkey '^P' up-history -#bindkey '^N' down-history -#bindkey '^?' backward-delete-char -#bindkey '^h' backward-delete-char -#bindkey '^w' backward-kill-word -#bindkey '^r' history-incremental-search-backward -# -#bindkey "\e[1~" beginning-of-line -#bindkey "\e[4~" end-of-line -#bindkey "\e[5~" beginning-of-history -#bindkey "\e[6~" end-of-history -#bindkey "\e[3~" delete-char -#bindkey "\e[2~" quoted-insert -#bindkey "\e[5C" forward-word -#bindkey "\eOc" emacs-forward-word -#bindkey "\e[5D" backward-word -#bindkey "\eOd" emacs-backward-word -#bindkey "\ee[C" forward-word -#bindkey "\ee[D" backward-word -# -#bindkey "^H" backward-delete-word - -# --------------------------------------------------------------------------------------------------------------------- -# ==> KEY BINDINGS - EMACS bindings because I work on lots of different machines -# so I should get used to the defaults -# -bindkey -e -setopt interactivecomments -export KEYTIMEOUT=1 - -# --------------------------------------------------------------------------------------------------------------------- -# ==> FZF -# -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh -# Include hidden files -export FZF_DEFAULT_COMMAND='find .' - -# --------------------------------------------------------------------------------------------------------------------- -# ==> set PATH so it includes user's private ~/bin if present -PATH="$PATH:$HOME/.local/bin:$HOME/bin" - -# --------------------------------------------------------------------------------------------------------------------- -# ==> set PATH so it includes /usr/games if present -PATH="$PATH:/usr/games" - -# --------------------------------------------------------------------------------------------------------------------- -# ==> Powerlevel10k https://github.com/romkatv/powerlevel10k -# -# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. -[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh +# Instant Prompt Preamble # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Initialization code that may require console input (password prompts, [y/n] -# confirmations, etc.) must go above this block, everything else may go below. +# confirmations, etc.) must go above this block; everything else may go below. if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi -# --------------------------------------------------------------------------------------------------------------------- -# ==> Enable rootless control of virsh, if installed -# -if [[ -f /usr/bin/virsh ]]; then - export LIBVIRT_DEFAULT_URI=qemu:///system -fi -# --------------------------------------------------------------------------------------------------------------------- -# ==> Show me a fortune tux when I log in! -# -fortune -a | cowsay -f tux +# If .fzf.zsh exists, source it +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + +# If .p10k.zsh exists, source it +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh + +# If .zshrc.$USER exists, source it +[[ ! -f ~/.zshrc.$USER ]] || source ~/.zshrc.$USER diff --git a/README.md b/README.md index 0ef0ca5..fcff118 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # dotfiles-zsh -A dotfile repo for zsh-specific dotfiles. Includes setting for [oh-my-zsh ](https://github.com/robbyrussell/oh-my-zsh) -(required) - +Just a place to track my `.zshrc`. +Includes setting for [oh-my-zsh ](https://github.com/robbyrussell/oh-my-zsh) (required)