Skip to content

Commit

Permalink
cleaned up unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
timmermansjoy committed Nov 28, 2024
1 parent 35366e1 commit ad4bd08
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 87 deletions.
4 changes: 0 additions & 4 deletions basic/functions/_c

This file was deleted.

12 changes: 0 additions & 12 deletions basic/functions/c

This file was deleted.

43 changes: 21 additions & 22 deletions basic/functions/extract
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
# Usage: extract <file>
# Description: extracts archived files / mounts disk images
# Note: .dmg/hdiutil is Mac OS X-specific.
extract () {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar -jxvf $1 ;;
*.tar.gz) tar -zxvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.dmg) hdiutil mount $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar -xvf $1 ;;
*.tbz2) tar -jxvf $1 ;;
*.tgz) tar -zxvf $1 ;;
*.zip) unzip $1 ;;
*.ZIP) unzip $1 ;;
*.pax) cat $1 | pax -r ;;
*.pax.Z) uncompress $1 --stdout | pax -r ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted/mounted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
extract() {
if [ -f $1 ]; then
case $1 in
*.tar.bz2) tar -jxvf $1 ;;
*.tar.gz) tar -zxvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.dmg) hdiutil mount $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar -xvf $1 ;;
*.tbz2) tar -jxvf $1 ;;
*.tgz) tar -zxvf $1 ;;
*.zip) unzip $1 ;;
*.ZIP) unzip $1 ;;
*.pax) cat $1 | pax -r ;;
*.pax.Z) uncompress $1 --stdout | pax -r ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted/mounted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}

18 changes: 8 additions & 10 deletions basic/shell/custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
# Custom functions

function top_commands {
cat ~/.zsh_history | format_history | head -n20
cat ~/.zsh_history | format_history | head -n20
}

alias tc=top_commands

function top_recent_commands {
tail -n1000 ~/.zsh_history | format_history | head -n20
tail -n1000 ~/.zsh_history | format_history | head -n20
}
alias trc=top_recent_commands

function format_history {
cut -d ';' -f 2- 2>/dev/null |
awk '{a[$1]++ } END{for(i in a){print a[i] " " i}}' |
sort -rn
cut -d ';' -f 2- 2>/dev/null |
awk '{a[$1]++ } END{for(i in a){print a[i] " " i}}' |
sort -rn
}

# Get weather report
function weather {
curl -s "http://wttr.in/${1:-Hasselt}" | head -n 27
curl -s "http://wttr.in/${1:-Hasselt}" | head -n 27
}
alias weer="weather"

# Get wifi password of given SSID
function wifi_password {
wifi_name=$1
security find-generic-password -ga "$wifi_name" | grep "password:"
wifi_name=$1
security find-generic-password -ga "$wifi_name" | grep "password:"
}

#remap defaults
Expand All @@ -40,10 +40,8 @@ alias lhost="open http://localhost:8080"
alias localh="open http://localhost:8080"
alias dotfile='e ~/.dotfiles'
alias dotfiles='e ~/.dotfiles'
alias cpu="htop"
alias myip="curl http://ipecho.net/plain; echo"
alias finder="open ."
alias pxl="cd /Users/Joy/Stack/PXL/3e_jaar"

# Programs shortcuts
alias s="osascript -e 'tell application \"Safari\" to activate'"
Expand Down
80 changes: 41 additions & 39 deletions basic/shell/index.zsh
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
######################################
# config
# Ensure Shell Compatibility
######################################
if [[ -z "$ZSH_VERSION" ]]; then
echo "Error: This configuration is intended for zsh."
return 1
fi

######################################
# Validate DOTFILES Variable
######################################
if [[ -z "$DOTFILES" ]]; then
echo "Error: DOTFILES variable is not set."
return 1
fi

######################################
# Config
######################################
export LSCOLORS="exfxcxdxbxegedabagacad"
export CLICOLOR=true

# Load functions
fpath=($DOTFILES/basic/functions $fpath)
for file in $DOTFILES/basic/functions/*; do
[ -r "$file" ] && source "$file"
done

autoload -U $DOTFILES/basic/functions/*(:t)
# Initialize completion system
autoload -Uz compinit
compaudit | xargs chmod g-w,o-w 2>/dev/null
compinit -u

HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000

setopt NO_BG_NICE # don't nice background tasks
setopt NO_HUP
setopt NO_LIST_BEEP
setopt LOCAL_OPTIONS # allow functions to have local options
setopt LOCAL_TRAPS # allow functions to have local traps
setopt HIST_VERIFY
setopt SHARE_HISTORY # share history between sessions ???
setopt EXTENDED_HISTORY # add timestamps to history
setopt PROMPT_SUBST
setopt CORRECT
setopt COMPLETE_IN_WORD
setopt IGNORE_EOF

setopt APPEND_HISTORY # adds history
setopt INC_APPEND_HISTORY SHARE_HISTORY # adds history incrementally and share it across sessions
setopt HIST_IGNORE_ALL_DUPS # don't record dupes in history
setopt HIST_REDUCE_BLANKS

# don't expand aliases _before_ completion has finished
# like: git comm-[tab]
setopt NO_BG_NICE NO_HUP NO_LIST_BEEP LOCAL_OPTIONS LOCAL_TRAPS
setopt HIST_VERIFY SHARE_HISTORY EXTENDED_HISTORY PROMPT_SUBST
setopt CORRECT COMPLETE_IN_WORD IGNORE_EOF APPEND_HISTORY
setopt INC_APPEND_HISTORY SHARE_HISTORY HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS
setopt complete_aliases

bindkey '^[^[[D' backward-word
Expand All @@ -42,39 +49,34 @@ bindkey '^[[3~' delete-char
bindkey '^?' backward-delete-char

######################################
# window
# Window
######################################
# From http://dotfiles.org/~_why/.zshrc
# Sets the window title nicely no matter where you are
function title() {
# escape '%' chars in $1, make nonprintables visible
a=${(V)1//\%/\%\%}

# Truncate command, and join lines.
a=$(print -Pn "%40>...>$a" | tr -d "\n")
local input="${1:-Untitled}"
local escaped_input="${input//\%/\%\%}"
local truncated=$(print -Pn "%40>...>$escaped_input" | tr -d "\n")

case $TERM in
screen)
print -Pn "\ek$a:$3\e\\" # screen title (in ^A")
print -Pn "\ek$truncated:$3\e\\"
;;
xterm*|rxvt)
print -Pn "\e]2;$2\a" # plain xterm title ($3 for pwd)
xterm* | rxvt)
print -Pn "\e]2;$truncated\a"
;;
*) ;;
esac
}

######################################
# completion
# Completion
######################################
# matches case insensitive for lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

# pasting with tabs doesn't perform completion
zstyle ':completion:*' insert-tab pending
zstyle ':completion:*' completer _complete _ignored _approximate
zstyle ':completion:*' verbose yes

######################################
# customizations
# Customizations
######################################
source $DOTFILES/basic/shell/custom.sh

chpwd() ls -F

0 comments on commit ad4bd08

Please sign in to comment.