iTerm2: Add Keystroke to move between words

On a Mac, I use iTerm2 as my default terminal due to the added features, such as auto-copy and the ability to split multiple terminals. One nuance was not having the ability to move between words (like in vim); however, I found the below how-to on Stack Overflow — where else? 🙂

  1. Go to Preferences, Profile, Keys.
  2. Set your left ? key to act as an escape character.
  3. Locate the current shortcut for ? ? or create a new one, with the following settings:
    • Keyboard Shortcut: ??
    • Action: Send Escape Sequence
    • Esc+: b
  4. repeat for the ?? keyboard shortcut with the following settings:
    • Keyboard Shortcut: ??
    • Action: Send Escape Sequence
    • Esc+: f

From this point, you can use Option + [left/right arrow keys]. Yass, productivity skill level increase! Later.

Mac OS Catalina: “invalid active developer path” error

After upgrading to Catalina, I encountered the error below. Seems Xcode was no longer available.


xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Try the following in your terminal; otherwise, head to https://developer.apple.com/download/more/ and download Xcode manually.


xcode-select --install

How to add environment variables in Mac OS X

Adding here for reference (tried this in Mac OS X Mojave):


# To set an environment variable, enter the following command:
launchctl setenv variable "value"

# To find out if an environment variable is set, use the following command:
launchctl getenv variable

# To clear an environment variable, use the following command:
launchctl unsetenv variable

My .bash_profile

Don’t know why I never added it here, so doing it now.


alias ll="ls -al"
alias src="cd ~/workspace/"
alias ap="cd ~/workspace/git/antonperez/"

alias readyapi=”/Applications/ReadyAPI-2.5.0.app/Contents/java/app/bin/ready-api.sh”

performGitOperations() {
git fetch –all
git checkout $1
git reset –hard origin/$1
git clean -fd
}

copom() {
echo “[———- START ———-]”
if [ “$2” = “all” ]; then
echo “–>> blwebdriver <<–” cd ~/workspace/git/qa/blwebdriver performGitOperations $1 echo “–>> blutilities <<–” cd ~/workspace/git/qa/blutilities performGitOperations $1 fi echo “–>> blpages <<–” cd ~/workspace/git/qa/blpages performGitOperations $1 echo “–>> blcucumber <<–”
cd ~/workspace/git/qa/blcucumber
performGitOperations $1
echo “[———- DONE ———-]”
}

 

git-all() {
git fetch –all
git checkout $1
git reset –hard origin/$1
git clean -fd
}

if [ -f $(brew –prefix)/etc/bash_completion ]; then
. $(brew –prefix)/etc/bash_completion
fi

gitPS1(){
gitps1=$(git branch 2>/dev/null | grep ‘*’)
gitps1=”${gitps1:+ (${gitps1/#\* /})}”
echo “$gitps1”
}

PS1=’\u@\h:\w$(gitPS1)$ ‘