From bbdaad41b1f4234c6b071a6d7f9fc21a648458ea Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Thu, 16 Jul 2020 23:59:22 +0100 Subject: [PATCH] Add bash functions --- bash/.bash_aliases | 8 ++++++++ bash/.bash_functions | 28 ++++++++++++++++++++++++++++ bash/.bashrc | 22 ++++++++++------------ bin/bin/add-sshkey | 14 -------------- bin/bin/update-dotfiles | 10 ---------- 5 files changed, 46 insertions(+), 36 deletions(-) create mode 100644 bash/.bash_aliases create mode 100644 bash/.bash_functions delete mode 100644 bin/bin/add-sshkey delete mode 100644 bin/bin/update-dotfiles diff --git a/bash/.bash_aliases b/bash/.bash_aliases new file mode 100644 index 0000000..266d1cc --- /dev/null +++ b/bash/.bash_aliases @@ -0,0 +1,8 @@ +# OSX aliases +if [ $(uname) == "Darwin" ]; then + alias ls="ls -FG" +else + alias ls="ls -F --color=auto" +fi + +alias tma="tmux attach" diff --git a/bash/.bash_functions b/bash/.bash_functions new file mode 100644 index 0000000..6d690c1 --- /dev/null +++ b/bash/.bash_functions @@ -0,0 +1,28 @@ + +# Git pulls latest dotfiles +function update-dotfiles() { + if [ -d "${HOME}/.dotfiles" ]; then + cd $HOME/.dotfiles + git pull --rebase --autostash + fi + if [ -d "${HOME}/.dotfiles-private" ]; then + cd $HOME/.dotfiles-private + git pull --rebase --autostash + fi +} + +function add-sshkey() { + TIMEOUT="1h" + NAME=$1 + + if [ -z "$NAME" ]; then + echo "Current Keys" + ssh-add -L + else + if [ -f "~/.ssh/id_ed25519_${NAME}" ]; then + ssh-add -t $TIMEOUT "~/.ssh/id_ed25519_${NAME}" + else + echo "No key named ${NAME} found..." + fi + fi +} \ No newline at end of file diff --git a/bash/.bashrc b/bash/.bashrc index cc3fac7..ab4d0f6 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -5,18 +5,16 @@ if [ -f /etc/bashrc ]; then . /etc/bashrc fi +# Source functions, if it exists +if [ -e $HOME/.bash_functions ]; then + source $HOME/.bash_functions +fi + +# Source aliases, if it exists +if [ -e $HOME/.bash_aliases ]; then + source $HOME/.bash_aliases +fi + # User specific environment PATH="$HOME/.local/bin:$HOME/bin:$PATH" export PATH - -# Uncomment the following line if you don't like systemctl's auto-paging feature: -# export SYSTEMD_PAGER= - -# User specific aliases and functions - -# OSX aliases -if [ $(uname) == "Darwin" ]; then - alias ls="ls -FG" -else - alias ls="ls -F --color=auto" -fi diff --git a/bin/bin/add-sshkey b/bin/bin/add-sshkey deleted file mode 100644 index a121043..0000000 --- a/bin/bin/add-sshkey +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -TIMEOUT="1h" -NAME=$1 - -if [ -z "$NAME" ]; then - ssh-add -L -else - if [ -f "~/.ssh/id_ed25519_${NAME}" ]; then - ssh-add -t $TIMEOUT "~/.ssh/id_ed25519_${NAME}" - else - echo "No key named ${NAME} found..." - fi -fi \ No newline at end of file diff --git a/bin/bin/update-dotfiles b/bin/bin/update-dotfiles deleted file mode 100644 index 2d22b3a..0000000 --- a/bin/bin/update-dotfiles +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -if [ -d "${HOME}/.dotfiles" ]; then - cd $HOME/.dotfiles - git pull --rebase --autostash -fi -if [ -d "${HOME}/.dotfiles-private" ]; then - cd $HOME/.dotfiles-private - git pull --rebase --autostash -fi \ No newline at end of file