diff --git a/bash/.aliases b/bash/.aliases index e03df9a1..dd972ac1 100644 --- a/bash/.aliases +++ b/bash/.aliases @@ -82,6 +82,7 @@ alias xcode='open -a xcode' # --------------------------------------------------------------------------- # 3. Quicker navigation # --------------------------------------------------------------------------- +alias ~="cd ~" alias ...='cd ../../' # Go back 2 directory levels alias ..='cd ../' # Go back 1 directory level alias .3='cd ../../../' # Go back 3 directory levels diff --git a/bash/.bash_profile b/bash/.bash_profile index 91cca10a..12101e4b 100644 --- a/bash/.bash_profile +++ b/bash/.bash_profile @@ -72,12 +72,12 @@ test -f "$HOME/.bashrc" && source "$HOME/.bashrc" # 2. Change prompt # --------------------------------------------------------------------------- -# Root prompt (RED) -SUDO_PS1="$(tput setaf 1)[\\d \\t] @ $(tput setaf 7)\\h(💀 \\u): $" +# Root prompt (😈) +SUDO_PS1="\[root@$(hostname -f) 😈: $ " export SUDO_PS1 -# Normal prompt (WHITE) -PS1="$(tput setaf 7)[\\d \\t] @ \\h(👽 \\u): $" +# Normal prompt (👽) +PS1="$(hostname -f) 👽: $ " export PS1 @@ -199,7 +199,7 @@ function rm() { done } -# cd: function to Enable 'cd' into directory aliases +# cd: Function to Enable 'cd' into directory aliases function cd() { if [ ${#1} == 0 ]; then builtin cd @@ -213,6 +213,56 @@ function cd() { fi } +# tree: Function to generates a tree view from the current directory +function tree(){ + pwd + ls -R | grep ":$" | \ + sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' +} + +# sshKeyGen: Function to generates SSH key +function sshKeyGen() { + + echo "What's the name of the Key (no spaced please) ? "; + read -r name; + + echo "What's the email associated with it? "; + read -r email; + + $(ssh-keygen -t rsa -f ~/.ssh/id_rsa_$name -C "$email"); + + ssh-add ~/.ssh/id_rsa_$name; + + pbcopy < ~/.ssh/id_rsa_$name.pub; + + echo "SSH Key copied in your clipboard"; + +} + +# filestolower: Function to rename all the files which contain uppercase letters to lowercase in the current folder +function filestolower(){ + read -r -p "This will rename all the files and directories to lowercase in the current folder, continue? [y/n]: " letsdothis + if [ "$letsdothis" = "y" ] || [ "$letsdothis" = "Y" ]; then + for x in `ls` + do + skip=false + if [ -d $x ]; then + read -p "'$x' is a folder, rename it? [y/n]: " renamedir + if [ "$renamedir" = "n" ] || [ "$renameDir" = "N" ]; then + skip=true + fi + fi + if [ "$skip" == "false" ]; then + lc=`echo $x | tr '[A-Z]' '[a-z]'` + if [ $lc != $x ]; then + echo "renaming $x -> $lc" + mv $x $lc + fi + fi + done + fi +} + # mkcd: Function to combine mkdir and cd mkcd() { mkdir "$1" @@ -268,6 +318,29 @@ extract() { fi } +# Generates a random password +function randompwd() { + if [ -z $1 ]; then + MAXSIZE=10 + else + MAXSIZE=$1 + fi + array1=( + q w e r t y u i o p a s d f g h j k l z x c v b n m Q W E R T Y U I O P A S D + F G H J K L Z X C V B N M 1 2 3 4 5 6 7 8 9 0 + \! \@ \$ \% \^ \& \* \! \@ \$ \% \^ \& \* \@ \$ \% \^ \& \* + ) + MODNUM=${#array1[*]} + pwd_len=0 + while [ $pwd_len -lt $MAXSIZE ] + do + index=$(($RANDOM%$MODNUM)) + echo -n "${array1[$index]}" + ((pwd_len++)) + done + echo +} + # mcd: Function to makes new Dir and jumps inside mcd() { mkdir -p "$1" && cd "$1" || exit; } diff --git a/package.json b/package.json index 6f7c0157..4eafacac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reedia-dotfiles", - "version": "0.1.57", + "version": "0.1.59", "description": "Dotfiles - A set of Mac OS X configuration files", "keywords": [ "dotfiles",