Skip to content

Instantly share code, notes, and snippets.

@danieltomasz
Last active June 19, 2018 16:56
Show Gist options
  • Save danieltomasz/bc57db1a4a40c1afdd9a3eda87d06561 to your computer and use it in GitHub Desktop.
Save danieltomasz/bc57db1a4a40c1afdd9a3eda87d06561 to your computer and use it in GitHub Desktop.
bash shortcuts
cd - # go to previuos directory
pushd level-1/level-2
# do work ...
popd 
# now we're back to the directory we started in
alias o="xdg-open" # o stands for open 
o file #will open file in default aplication
o .

!! Repeats your last command
sudo !! # repeat last command with sudo
mkdir -p make/new/directory
cd !$
#  cd is taking last  argument from the previus command

# Renaming/moving files with suffixes quickly:
cp /home/foo/realllylongname.cpp{,-old}

# This expands to:
cp /home/foo/realllylongname.cpp /home/foo/realllylongname.cpp-old

# to do the reverse (going from .cpp-old to .cpp) you'd do 
cp /home/foo/realllylongname.cpp{-old
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment