From 60cee5b38a83df90c3705372dff53506b2d88e71 Mon Sep 17 00:00:00 2001 From: MorganGeek Date: Sun, 12 Jul 2020 17:50:17 +0200 Subject: [PATCH] ansible/blog aliase + improve UX for some functions - improve behavior of clone function to show more output - add alias for going ti blog editing mode - aliases for ansible ad-hoc command invocation --- dot_zsh_aliases | 3 +++ dot_zsh_functions | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dot_zsh_aliases b/dot_zsh_aliases index dc0dbb3..0015b1a 100644 --- a/dot_zsh_aliases +++ b/dot_zsh_aliases @@ -151,6 +151,7 @@ alias dots='cd $HOME/Code/dotfiles' alias dotfiles='dots' alias code='cd $HOME/Code' alias gochezmoi='cd ~/.local/share/chezmoi' +alias blog='z morgangeek-blog' # System Utils alias systeminfo='neofetch' @@ -174,6 +175,8 @@ alias help='tldr' alias latency='curl cheat.sh/latency' # Misc +alias adhoc="ansible --one-line 127.0.0.1 -m" +alias ans='adhoc' alias bash="/usr/local/bin/bash" #alias date="gdate" alias current_year='`echo date +"%Y"`' diff --git a/dot_zsh_functions b/dot_zsh_functions index 529de28..e1b05cf 100644 --- a/dot_zsh_functions +++ b/dot_zsh_functions @@ -125,6 +125,8 @@ function suggest_aliases() { arrow "$alias_line" done < <(echo "$matching_aliases") echo + else + warning "no alias for $line" fi done < <(top_commands_full "" "$search_input_size" | awk '{ $1=""; $2=""; $3=""; print}' | awk 'NF' | awk '{$1=$1};1' | awk -v COUNT=1 'NF>COUNT' | head "-$search_input_size") } @@ -329,7 +331,7 @@ function git-project() { REPO_PATH="$(pwd)" fi local preview='lsd --color always --icon always --group-dirs first {}' - local dir=$(find $REPO_PATH -maxdepth 3 -type d -name ".git" | sed 's#.git$##' | fzf --select-1 --query="$*" --preview "$preview") + local dir=$(find "$REPO_PATH" -maxdepth 3 -type d -name ".git" | sed 's#.git$##' | fzf --select-1 --query="$*" --preview "$preview") if [[ -n "$dir" ]]; then cd "$dir" || exit fi @@ -375,10 +377,13 @@ function gitpushallremote() { function clone() { local folder=$(basename $1 | sed 's/\.git.*//g') arrow "git project identified as $folder" + arrow "cloning repository ..." if gcls "$1"; then + success "repository cloned" if [[ -n "$folder" ]]; then cd "$folder" || exit if [[ "$string:u" =~ "$COMPANY_NAME:u" ]]; then + arrow "copying pre-commit hooks ..." copyhooks fi else @@ -398,22 +403,22 @@ function colorpic() { } function brewadd() { brew install "$1" - ansible 127.0.0.1 -m lineinfile -a "path=~/Brewfile line='brew \"$1\"'" + adhoc lineinfile -a "path=~/Brewfile line='brew \"$1\"'" } function pipadd() { pip install "$1" pip freeze >"$HOME/requirements.txt" } function goadd() { - ansible 127.0.0.1 -m lineinfile -a "path=~/.scripts/godeps.sh line='go get -u -v $1'" + adhoc lineinfile -a "path=~/.scripts/godeps.sh line='go get -u -v $1'" go get -u -v "$1" } function rssadd() { - ansible 127.0.0.1 -m lineinfile -a "path=~/.newsboat/urls line='"$1"'" + adhoc lineinfile -a "path=~/.newsboat/urls line='"$1"'" newsboat } function bookmarkadd() { - ansible 127.0.0.1 -m lineinfile -a "path=$HOME/Code/bookmarks/README.md insertafter='"$1"' line='* "$2"'" + adhoc lineinfile -a "path=$HOME/Code/bookmarks/README.md insertafter='"$1"' line='* "$2"'" } function backupgithub() { curl -sL "https://api.github.com/users/$1/repos" | jq -r '.[] | .ssh_url' | xargs -n1 git clone --mirror --no-hardlinks