DEV Community

Discussion on: What are your favorite bash aliases?

Collapse
 
whusterj profile image
William Huster • Edited

I use Ubuntu -- I have a ~/scripts directory, where I put useful scripts. I then alias these for quick use.

Here's a shortcut to open any VSCode workspace saved in ~/workspace/vscode-workspaces/

#!/bin/bash
#
# Author: William Huster
# Description: Shortcut to open a VSCode workspace
#
code $HOME/workspace/vscode-workspaces/$1.code-workspace

In ~/.bashrc:

alias workspace="bash $SCRIPTS_DIR/vscode-workspace.sh"

I also have a git-versioned folder for notes in markdown. I like to create a file for daily notes, so I have note alias and script to create/open that file:

#!/bin/bash
#
# Author: William Huster
# Description: Shortcut to launch an editor with my today's notes.
#
WORKSPACE_DIR=~/workspace
NOTES_DIR=~/notes

cd $NOTES_DIR

# Make the filename
NOW=$(date +"%Y-%m-%d")
NOTE_TITLE="__Notes.md"
todays_notes="$NOW$NOTE_TITLE"

# Open it!
code $WORKSPACE_DIR/vscode-workspaces/notes.code-workspace "$todays_notes"

In ~/.bashrc:

alias note="bash $SCRIPTS_DIR/take-note.sh"
Collapse
 
roelofjanelsinga profile image
Roelof Jan Elsinga

That's definitely something I should do! Such great ideas, thank you for these!