Skip to content

Commit

Permalink
feat(zsh): improve aliases
Browse files Browse the repository at this point in the history
- Jump to favorite locations
  - Add alias: `github-d2s`
- Location related aliases
  - Improve alias: `pwdcopy`
    - Use `xclip -selection clipboard` for Linux desktop environments
- Improve `grep` command detection
  - Potentially faster with native ZSH features instead of a shell command
- SSH Key management
  - Remove old duplicate SSH key management alias
  - Merge it to Linux version, allowing for better multi-platform compatiblity
  • Loading branch information
d2s committed Oct 11, 2019
1 parent c6b68d7 commit 2ef24ab
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions zsh/aliases.zsh
Expand Up @@ -22,14 +22,17 @@ fi
if [ $PROJECTS ] ; then
alias projects="cd $PROJECTS"
alias github="cd $PROJECTS/github.com"
alias github-d2s="cd $PROJECTS/github.com/d2s"
fi


# -----------------------------------------------------------
# Location related aliases

if [ "$OS" = "darwin" ] ; then
# Copy name of current workind directory to clipboard
# Copy name of current workind directory to clipboard
if [ "$SYSTEMTYPE" = "linux" ] ; then
alias pwdcopy="pwd | xclip -selection clipboard"
elif [ "$OS" = "darwin" ] ; then
alias pwdcopy="pwd | pbcopy"
fi

Expand All @@ -39,7 +42,8 @@ alias ducks="du -cksh * | sort -rn|head -11"


# -----------------------------------------------------------
if [ "$(command -v grep)" ]; then
# If `grep` is available
if type -p grep &>/dev/null; then
# grep through history
#
# Usage:
Expand Down Expand Up @@ -222,16 +226,6 @@ if type -p ip &>/dev/null; then
fi


# -----------------------------------------------------------
# SSH public key to clipboard
if [ -f ~/.ssh/id_rsa.pub ]; then
if [ "$OS" = "darwin" ] ; then
alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | echo '=> Public key copied to clipboard.'"
fi
# TODO: Find similar command for other systems.
fi


# -----------------------------------------------------------
# System information tools

Expand Down Expand Up @@ -317,8 +311,14 @@ alias untar="tar xvf"
# SSH Key management
# -----------------------------------------------------------

# Pipe my public key to clipboard
alias pubkey="more ~/.ssh/id_rsa.pub | xclip -selection clipboard | echo '=> SSH Public key copied to pasteboard.'"
# Pipe my SSH public key to clipboard
if [ -f ~/.ssh/id_rsa.pub ]; then
if [ "$SYSTEMTYPE" = "linux" ] ; then
alias pubkey="more ~/.ssh/id_rsa.pub | xclip -selection clipboard | echo '=> SSH Public key copied to pasteboard.'"
elif [ "$OS" = "darwin" ] ; then
alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | echo '=> SSH Public key copied to pasteboard.'"
fi
fi

# Pipe my private key to clipboard
# alias prikey="more ~/.ssh/id_rsa | xclip -selection clipboard | echo '=> SSH Private key copied to pasteboard.'"
Expand Down

0 comments on commit 2ef24ab

Please sign in to comment.