Skip to content

Instantly share code, notes, and snippets.

@httpsterio
Last active April 26, 2018 09:55
Show Gist options
  • Save httpsterio/be8197c57a568ad5cb650cbd5875ac24 to your computer and use it in GitHub Desktop.
Save httpsterio/be8197c57a568ad5cb650cbd5875ac24 to your computer and use it in GitHub Desktop.
A few handy bash commands I created for my own needs.
cpath () {
pwd > ~/.pathfile
echo 'path copied'
}
ppath () {
cd $(cat ~/.pathfile)
}
cfile () {
cat $1 > ~/.copyfile
echo 'file content copied'
}
pfile () {
cat ~/.copyfile
}
@httpsterio
Copy link
Author

This is a part of my .bashrc.

It's a series of commands that allows you to save a folder location and cd into it, for example when invoking a new terminal and you want to jump to the place where you were quickly.

It also allows you to output a file content into a file and output the saved content. I use it for example to copy a file's content so that I can pass it to another command like "pfile | tail -c 5" to get the last five characters of a file, without the need to write the full path to the files.

cpath = copy path
ppath = paste path (aka cd into saved path)
cfile = copy file content
pfile = paste file content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment