Here are a handful I use most days at the moment, saving myself some mouse clicks and key strokes.

Quickly open Jira tickets

This is a simple one for opening a new tab at the Jira ticket related to the current git branch you’re on.

Most branches I work on have a specific format — the story/ticket number followed by an an underscore then a short summary of the story’s purpose.

e.g. XYZ-738_AddSupportForDotNetCore

So hitting jira jumps me straight to the story I want to see by extracting the story number out of the current git branch’s name and tacking it on to the relevant URL to open in the browser.

alias jira='xdg-open "https://mycompany.atlassian.net/browse/$(git rev-parse --abbrev-ref HEAD | grep -o "^[A-Za-z]\+-[0-9]\+")"'

There’s no error handling around it so running it in a non-git directory or on a branch with a name in a different format may have strange results.

Piping to the clipboard

Sometimes it’s handy to be able to send the output of some command to the clipboard.

alias clip='xclip -selection c'

Open a file in the default application

Open files, paths and URLs with their default program.

alias go='xdg-open'

Backing up files

Unsure about making a change to a file? Run bak myfile.txt and have a backup copy if something goes wrong.

bak() {
  cp $1{,.backup}
}

Jumping up directories

Here’s a quicker way of cding up n directories

alias ..='cd ..'
alias ...='cd ../../'
alias ....='cd ../../../'

Finding things in directories

Looking for a file or directory but can’t remember the exact name? List the contents of the directory but filter down the results with grep.

alias lg='ll | grep -i'