From 0730b2f039124366fb8e52195192e5d288fffcab Mon Sep 17 00:00:00 2001 From: MorganGeek Date: Fri, 3 Jul 2020 06:22:30 +0200 Subject: [PATCH] add aliases inspired - inspired partially by https://github.com/sapegin/dotfiles/blob/master/zsh/aliases.zsh --- dot_zsh_aliases | 22 +++++++++++++++------- dot_zsh_functions | 10 +++++++--- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/dot_zsh_aliases b/dot_zsh_aliases index 213493d..50e97d7 100644 --- a/dot_zsh_aliases +++ b/dot_zsh_aliases @@ -65,7 +65,10 @@ alias engines='sr -elvi' alias grep='rg' alias usernames="python3 $HOME/Code/sherlock/sherlock.py --rank --print-found" alias ygg="torrengo -s ygg" -alias ag='alias | grep' # search for patten among aliases +alias ag='alias | grep -i' # search for patten among aliases +alias hg='history | grep -i' # search for pattern among history +alias hist='history' + # Events alias agenda='calendar' alias mails="gmail && gmail2" @@ -92,6 +95,10 @@ alias newpass='bw generate --special --uppercase --lowercase --number --length 3 alias ip='echo $(curl ident.me -4 2>/dev/null)' alias ipinfo='curl "ipinfo.io/"$(ip)' alias getips='\egrep "\b(([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}(1[0-9][0-9]|2[0-4][0-9]|25[0-5]|[0-9]{1,2})\b"' +alias ping='prettyping -c 5 --nolegend' # Stop after sending count ECHO_REQUEST packets + +# Downloads +alias get="curl -O -L" # Download file and save it with filename of remote file # Files & folder tricks alias biggerthan10='biggerthan 10M' @@ -107,8 +114,9 @@ alias du='ncdu --color dark -rr -x --exclude .git --exclude node_modules' alias s=ls alias sl=ll alias ls='lsd' -alias lsg='ll | grep' # show me files matching "ls grep" +alias lsg='ll | grep -i' # show me files matching "ls grep" alias lh='ls -alt | head' # see the last modified files + alias tree='ls --almost-all --tree' alias v=vi alias x='extract' @@ -118,6 +126,8 @@ alias x='extract' alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'" alias ve='vim ~/.vimrc' # vimrc editing alias ze='vim ~/.zshrc' # zsh profile editing +alias zf='vim ~/.zsh_functions' # edit zsh_functions +alias za='vim ~/.zsh_aliases' # edit zsh_aliases # System info alias systeminfo='neofetch' @@ -126,6 +136,7 @@ alias monitoring='glances' # System Utils alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" # Lock the screen (when going AFK) alias reload="exec ${SHELL} -l" # Reload the shell (i.e. invoke as a login shell) +alias sc="source $HOME/.zshrc" # Infrastructure alias awsls='awsls -profile default -region eu-west-1 --attributes tags aws_instance' @@ -141,16 +152,13 @@ alias latency='curl cheat.sh/latency' # Misc alias bash="/usr/local/bin/bash" +alias current_year='`echo date +"%Y"`' alias headers='curl -I --compress' # Find out if remote server supports gzip / mod_deflate or not # -alias hist='history' -alias path='echo -e ${PATH//:/\\n}' # Explode and display current PATH -alias ping='prettyping -c 5 --nolegend' # Stop after sending count ECHO_REQUEST packets alias https='http --default-scheme=https' # useful alias stealed from a colleague. http is provided by httpie +alias path='echo -e ${PATH//:/\\n}' # Explode and display current PATH alias p='ps -ef | grep -i ' # Show matching processes. Usage : p alias root='sudo -i' -alias current_year='`echo date +"%Y"`' alias ':q'='exit' -alias sc="source $HOME/.zshrc" # Linters alias checken="aspell check -d en" diff --git a/dot_zsh_functions b/dot_zsh_functions index 3323eac..6d19ec1 100644 --- a/dot_zsh_functions +++ b/dot_zsh_functions @@ -96,16 +96,16 @@ function git_listobjectsbysize() { rm -f "$tempFile" } function top_commands() { - history | cat | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n50 + history | \cat | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n50 } function top_commands_full() { - history | cat | sed 's/^[0-9 TAB]*//g' | awk '{CMD[$0]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "%\t" a; }' | sort -nr | nl | head -n50 + history | \cat | sed 's/^[0-9 TAB]*//g' | awk '{CMD[$0]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "%\t" a; }' | sort -nr | nl | head -n50 } function istherenewissues() { LASTISSUE=$(newissues | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g' | awk 'FNR==2{print $2}') if [[ -f "$HOME/.newjiraissue" ]] then - previous_jira_issue=$(cat "$HOME/.newjiraissue" | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g') # the sed part is for removing output colors + previous_jira_issue=$(\cat "$HOME/.newjiraissue" | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g') # the sed part is for removing output colors if [ "$LASTISSUE" != "$previous_jira_issue" ]; then newissues else @@ -373,3 +373,7 @@ function rssadd { function backupgithub { curl -sL "https://api.github.com/users/$1/repos" | jq -r '.[] | .ssh_url' | xargs -n1 git clone --mirror --no-hardlinks } +# Make a directory and cd to it +function take { + mkdir -p $@ && cd ${@:$#} +}