Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function keyword #116

Merged
merged 1 commit into from
May 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions zsh/.zsh_functions
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,50 @@
# your own fork of the quickstart kit

# Add some quickstart toggle functions
zsh-quickstart-select-bullet-train() {
function zsh-quickstart-select-bullet-train() {
touch ~/.zsh-quickstart-use-bullet-train
rm -f ~/.zgen/init.zsh
}

zsh-quickstart-select-powerlevel10k() {
function zsh-quickstart-select-powerlevel10k() {
rm -f ~/.zsh-quickstart-use-bullet-train
rm -f ~/.zgen/init.zsh
}

zsh-quickstart-disable-omz-plugins() {
function zsh-quickstart-disable-omz-plugins() {
touch ~/.zsh-quickstart-no-omz
rm -f ~/.zgen/init.zsh
}

zsh-quickstart-enable-omz-plugins() {
function zsh-quickstart-enable-omz-plugins() {
rm -f ~/.zsh-quickstart-no-omz
rm -f ~/.zgen/init.zsh
}

exists() {
function exists() {
if (( $+commands[$1] )); then return 0; else return 1; fi
}

# from [email protected]
ff() {
function ff() {
find . -type f -iname '*'$@'*' -ls
}

hgrep_full() {
function hgrep_full() {
history | egrep --color -i "$@"
}

# easier to type, leaving hgrep_full for backwards compatibility
hgrep-full() {
function hgrep-full() {
hgrep_full "$@"
}

envgrep() {
function envgrep() {
printenv | grep -i "$@"
}

# From Dan Ryan's blog - http://danryan.co/using-antigen-for-zsh.html
man() {
function man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
Expand All @@ -67,31 +67,31 @@ man() {
}

# From commandlinefu.com
watch() { t=$1; shift; while test :; do clear; date=$(date); echo -e "Every $ts: $@ \t\t\t\t $date"; $@; sleep $t; done }
function watch() { t=$1; shift; while test :; do clear; date=$(date); echo -e "Every $ts: $@ \t\t\t\t $date"; $@; sleep $t; done }

# scp file to machine you're sshing into this machine from
mecp() {
function mecp() {
scp "$@" ${SSH_CLIENT%% *}:~/Downloads/;
}

calc() {
function calc() {
awk "BEGIN{ print $* }" ;
}

get_nr_jobs() {
function get_nr_jobs() {
jobs | wc -l
}

get_load() {
function get_load() {
uptime | awk '{print $11}' | tr ',' ' '
}

mtr_url() {
function mtr_url() {
host=$(ruby -ruri -e "puts (URI.parse('$1').host or '$1')")
sudo mtr -t $host
}

fix_tmux_ssh_agent() {
function fix_tmux_ssh_agent() {
for key in SSH_AUTH_SOCK SSH_CONNECTION SSH_CLIENT; do
if (tmux show-environment | grep "^${key}" > /dev/null); then
value=$(tmux show-environment | grep "^${key}" | sed -e "s/^[A-Z_]*=//")
Expand All @@ -101,28 +101,28 @@ fix_tmux_ssh_agent() {
}

# Probe a /24 for hosts
scan24() {
function scan24() {
nmap -sP ${1}/24
}

# Netjoin - Block until a network connection is obtained.
# Originally from https://github.com/bamos/dotfiles/blob/master/.funcs
nj() {
function nj() {
while true; do
ping -c 1 8.8.8.8 &> /dev/null && break
sleep 1
done
}

# lists zombie processes
zombie() {
function zombie() {
ps aux | awk '{if ($8=="Z") { print $2 }}'
}
alias zombies=zombie

# get the content type of an http resource
# from https://github.com/jleclanche/dotfiles/blob/master/.zshrc
htmime() {
function htmime() {
if [[ -z $1 ]]; then
print "USAGE: htmime <URL>"
return 1
Expand All @@ -132,7 +132,7 @@ htmime() {
}

# Start an HTTP server from a directory, optionally specifying the port
httpserver() {
function httpserver() {
local port="${1:-8000}";
sleep 1 && open "http://localhost:${port}/" &
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
Expand Down