Code Monkey home page Code Monkey logo

fresh's Introduction

fresh

Keep your dot files fresh.

fresh is a tool to source shell configuration (aliases, functions, etc) from others into your own configuration files. We also support files such as ackrc and gitconfig. Think of it as Bundler for your dot files.

You can use fresh search to find fresh lines that have been added to the directory.

Build Status

Contents

Installation

Install fresh with the following:

bash -c "`curl -sL https://get.freshshell.com`"

This will:

  • Create a ~/.fresh directory.
  • Clone the latest version of fresh into ~/.fresh/source/freshshell/fresh.
  • Create a ~/.freshrc file.

You will need to manually add source ~/.fresh/build/shell.sh to your shell config.

Manual steps

Don't want to run our shell script? The installation is simple:

git clone https://github.com/freshshell/fresh ~/.fresh/source/freshshell/fresh
echo "fresh freshshell/fresh bin/fresh --bin" >> ~/.freshrc
~/.fresh/source/freshshell/fresh/bin/fresh # run fresh
# Add `source ~/.fresh/build/shell.sh` to your shell config.

Usage

An example ~/.freshrc file:

# handles updating fresh
fresh freshshell/fresh bin/fresh --bin

# links your local ~/.dotfiles/gitconfig to ~/.gitconfig (you can change your local directory by setting $FRESH_LOCAL)
fresh gitconfig --file

# builds jasoncodes' aliases into ~/.fresh/build/shell.sh
fresh jasoncodes/dotfiles shell/aliases/\*

# builds the shell/aliases/git.sh file into ~/.fresh/build/shell.sh
fresh twe4ked/dotfiles shell/aliases/git.sh

# links the config/ackrc file to ~/.ackrc
fresh twe4ked/dotfiles config/ackrc --file

# builds config/notmuch-config.erb with erb and links it to ~/.notmuch-config
fresh neersighted/dotfiles config/notmuch-config.erb --file=~/.notmuch-config --filter=erb

# links the gemdiff file to ~/bin/gem-diff
fresh jasoncodes/dotfiles bin/gemdiff --bin=~/bin/gem-diff

# builds the aliases/github.sh file locked to the specified git ref
fresh twe4ked/dotfiles aliases/github.sh --ref=bea8134

Running fresh will then build your shell configuration and create any relevant symbolic links.

Sources

Local files

If no remote source is specified (github_user/repo_name), fresh will look for local files relative to ~/.dotfiles/.

For example the following fresh line will look for ~/.dotfiles/shell/aliases/git.sh.

fresh shell/aliases/git.sh

GitHub repositories

To source from a GitHub repository you can specify the username and repo name separated with a slash:

fresh username/repo example.sh

Non-GitHub sources

You can also source from non-GitHub repositories by specifying the full git clone URL:

fresh git://example.com/path/to/repo.git example.sh

Shell files

With no options, fresh will join specified shell files together.

fresh twe4ked/dotfiles shell/aliases/git.sh
fresh jasoncodes/dotfiles shell/aliases/\*

Joins the shell/aliases/git.sh file from twe4ked/dotfiles with the shell/aliases/* files from jasoncodes/dotfiles into ~/.fresh/build/shell.sh.

Config files

fresh twe4ked/dotfiles config/ackrc --file
fresh example/dotfiles pry.rb --file=~/.pryrc

Links the config/ackrc file from twe4ked/dotfiles to ~/.ackrc and the pry.rb file from example/dotfiles to ~/.pryrc.

A single config file built from multiple sources

fresh jasoncodes/dotfiles config/tmux.conf --file
fresh twe4ked/dotfiles config/tmux.conf --file

Builds tmux configuration from both jasoncodes/dotfiles and twe4ked/dotfiles together into a single ~/.tmux.conf output.

Identifying source files in compiled output

Shell files automatically include comments before each section. To add annotations to config files you can use the --marker option:

fresh twe4ked/dotfiles 'vim/*' --file=~/.vimrc --marker='"'
fresh jasoncodes/dotfiles config/pryrc --file --marker

Ordering globbed directories

Using a glob to source multiple files from a single directory will read files in alphabetical order. If you need to control the order in which files are sourced, you can create a .fresh-order file in the directory being globbed containing an ordered list of files to read first.

Sourcing whole directories of files

Whole directories or repositories can be built and symlinked by including a trailing slash on the --file path:

fresh mutt --file=~/.mutt/
fresh tpope/vim-pathogen . --file=~/.vim/bundle/vim-pathogen/ # whole repository

Building files without symlinking

Some tools/libraries (e.g. zsh plugins) require specific directory structures. These can be built within the build directory (~/.fresh/build) by specifying a relative path on --file:

fresh zsh-users/zsh-syntax-highlighting zsh-syntax-highlighting.zsh --file=vendor/zsh-syntax-highlighting.zsh
fresh zsh-users/zsh-syntax-highlighting highlighters --file=vendor/highlighters/

These files can then be sourced from your main shell config with:

source ~/.fresh/build/vendor/zsh-syntax-highlighting.zsh

Bin files

fresh jasoncodes/dotfiles bin/sedmv --bin
fresh jasoncodes/dotfiles bin/gemdiff --bin=~/bin/gem-diff

Links the sedmv file from jasoncodes/dotfiles to ~/bin/sedmv and the gemdiff file from jasoncodes/dotfiles to ~/bin/gem-diff.

Locking to specific Git references

fresh twe4ked/dotfiles aliases/github.sh --ref=bea8134

Locks the aliases/github.sh file to the specified commit. You can use any Git reference: branches, commit hashes, tags, etc.

Filters

Filters allow you to run specified files through arbitrary commands at build time.

fresh neersighted/dotfiles config/muttrc.erb.asc --file=~/.muttrc --filter="gpg | erb"

Option Blocks

If you have a section of your ~/.freshrc file where multiple lines need the same options you can use fresh-options to reduce duplication.

# ~/.freshrc
fresh-options --file=~/.vimrc --marker=\"
  fresh twe4ked/dotfiles vim/vundle_before.vim
  fresh vim/vundle.vim
  fresh twe4ked/dotfiles vim/vundle_after.vim
  fresh vim/mappings.vim
fresh-options

fresh-options overrides any previous fresh-options calls. Passing no arguments resets back to the default.

Advanced Usage

There are many other ways you can customize fresh. Check out our advanced usage wiki pages for more information.

Command line options

Install

Running fresh or fresh install will build shell configuration and relevant symlinks.

Update

Running fresh update will update sources from GitHub repositories and run fresh install.

You can also optionally supply a GitHub username or username/repo:

fresh update jasoncodes       # update all jasoncodes' repos
fresh update twe4ked/dotfiles # update twe4ked's dotfiles

Local dotfiles

fresh update without any arguments will also fetch any changes made to your local dotfiles stored in ~/.dotfiles. You can update just your local dofiles by specifying the --local option.

Clean

When you remove a source from your ~/.freshrc or remove a --file/--bin line, you can use fresh clean to remove dead symlinks and source repos.

Search

You can search our fresh directory using fresh search. Feel free to add your own fresh lines to the wiki page!

Try:

fresh search twe4ked
fresh search jasoncodes
# or
fresh search ruby

Edit

Running fresh edit will open your ~/.freshrc in your default $EDITOR.

Show

fresh show will output each line of your ~/.freshrc along with every source file those lines match. Handy for auditing.

Subcommands

fresh will detect bin files that start with fresh- in your $PATH.

For example running fresh open is equivalent to running fresh-open.

Adding Lines Directly From The Command line

You can append fresh lines to your freshrc directly from the command line.

Try running:

fresh twe4ked/catacomb bin/catacomb --bin
# or
fresh https://github.com/twe4ked/catacomb/blob/master/bin/catacomb

You will then get a prompt comfirming that you wish to add the new line. You can then modify it if needed by running fresh edit.

Maintainers

fresh is maintained by jasoncodes and twe4ked.

Licence

MIT

fresh's People

Contributors

akatov avatar bjeanes avatar dependabot[bot] avatar jasoncodes avatar joshuajabbour avatar jwerle avatar skorfmann avatar smstern avatar timoxley avatar twe4ked avatar vicendominguez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fresh's Issues

Use non-github repositories

Sometimes it would be useful to use a non-github repo. For example there are some git commands I have got from an account on gitorious, but fresh can't deal with that. With my previous hacked together solution I used a git submodule, but fresh is definitely a nicer way to do this.

I would leave the existing syntax alone. But if a full git URL was given, then fresh should use it as such. This is the way that vundle vim bundle manager) works and it seems like a good way to go for me.

Thanks for a great tool.

Comment to mark start of file output when sourcing different versions of the same file

When sourcing different versions of the same file, it'd be great if it added a comment to show where each version starts, e.g.

# ~/.freshrc
fresh jasoncodes/dotfiles tmux.conf --file
fresh twe4ked/dotfiles config/tmux.conf --file
# ~/.tmux.conf

# source: jasoncodes/dotfiles/tmux.conf
...
...

# source: twe4ked/dotfiles/config/tmux.conf
...
...

Display GitHub compare URLs in the update output

* Updating jasoncodes/dotfiles
| From http://github.com/jasoncodes/dotfiles
|    47ad84c..57b8b2b  master     -> origin/master
| First, rewinding head to replay your work on top of it...
| Fast-forwarded master to 57b8b2ba7482884169a187d46be63fb8f8f4146b.
<COMPARE URL HERE>
* Updating jasoncodes/scripts
| Current branch master is up to date.
* Updating robbyrussell/oh-my-zsh
| From http://github.com/robbyrussell/oh-my-zsh
|    22f827e..51e05b7  master     -> origin/master
| First, rewinding head to replay your work on top of it...
| Fast-forwarded master to 51e05b7579a26266a0ed26398ab9eb5071800cd8.
<COMPARE URL HERE>

Make it easier to update `~/.dotfiles`

Right now if you run fresh update on a secondary machine, your ~/.dotfiles repo is not automatically updated. This results in needing to do things such as cd ~/.dotfiles && git pull --rebase && fresh update instead.

I think fresh update without parameters should update ~/.dotfiles as well everything in ~/.fresh/source.

Ideally there should be a way to just update ~/.dotfiles without updating other repos too. I’d be fine with something like --local.

Script to verify Directory entries are valid

With dotfiles moving around it’s easy for entries in the Directory to become out of date. We should have a script which verifies every fresh line loads and every URL is reachable.

This could be implemented as a utility script in the fresh repo which retrieves all entries from the fresh API, builds up a test freshrc, runs fresh in isolation, and then curl -sLIs every URL to ensure they load.

Make it easier to add options to multiple fresh lines

In order to DRY up fresh lines with repeated options we need a way to set options for multiple lines.

fresh-options --file=~/.vimrc --marker=\"
  fresh vim/leader.vim
  fresh vim/vundle_before.vim
  fresh vim/vundle.vim
  fresh vim/vundle_after.vim
  fresh vim/functions.vim
  fresh vim/keybindings.vim
  fresh vim/plugin_config/\*
  fresh vim/vimrc
  fresh hackling/dotfiles vim/keybindings/numpad.vim
fresh-options # reset

fresh vim/gvimrc --file
fresh vim/colors --file=~/.vim/colors/

Warn when freshrc references local repo by name.

If the user/dotfiles is cloned to ~/.dotfiles, these files can be referenced in ~/.freshrc by omitting the repo name.
In this case there is no need to specify user/dotfiles. In fact, if you do, fresh will clone the repo again and you’ll have to push your changes before they’re available to fresh.

We should output a warning when fresh runs if ~/.dotfiles is a clone of a repo specified in ~/.freshrc.

Ideally this warning should include a corrected fresh line. There should also be a way to supress the warning (like FRESH_NO_BIN_CHECK).

Fresh says: "cannot remove directory `~/.fresh/build/bin'"

Hi Again,

Today I put fresh to the test and cloned my dot files at work.
Except I didn't because the following happened:

bash -c "`curl -sL get.freshshell.com`"
Initialized empty Git repository in /home/marks/.fresh/source/freshshell/fresh/.
git/
remote: Counting objects: 856, done.
remote: Compressing objects: 100% (359/359), done.
remote: Total 856 (delta 446), reused 793 (delta 383)
Receiving objects: 100% (856/856), 154.55 KiB, done.
Resolving deltas: 100% (446/446), done.
Your dot files are now fresh.

  __               _
 / _|             | |
| |_ _ __ ___  ___| |__
|  _| '__/ _ \\/ __| '_ \\
| | | | |  __/\\__ \\ | | |
|_| |_|  \\___||___/_| |_|
http://freshshell.com/

You're all ready to get fresh!

Add `source ~/.fresh/build/shell.sh` to your shell config.

Open a new shell, run `fresh edit` to start editing your .freshrc file
then run `fresh` to update your shell.

$ cat .freshrc
# freshshell.com
#
# Examples:
#
#   fresh twe4ked/dotfiles shell/functions.sh
#   fresh jasoncodes/dotfiles aliases/rails.sh
#   fresh jasoncodes/dotfiles config/tmux.conf --file
#
# See http://freshshell.com/readme for documentation.

# Fresh
fresh freshshell/fresh bin/fresh --bin

# All dotfiles into ~
fresh config/* --file

# Freemind config (could also add the custom icons here maybe)
fresh freemind/user.properties --file=~/.freemind/user.properties

# Do all the bin files into ~/bin at once, mwahaha
fresh bin --bin

# Mutt config all lives in .mutt
fresh mutt --file=~/.mutt/

$ fresh
rm: cannot remove directory `/home/marks/.fresh/build/bin': Directory not empty

Any idea what's going on here?

.freshrc is not empty because I first cloned my .dotfiles repo under ~/ and symlinked linked ~/.freshrc to ~/.dotfiles/freshrc.

I had omitted to source shell.sh but adding that doesn't change the above behaviour.
After doing the curl, my dot files are working, but after running fresh, fresh tries to delete itself.
Am I missing a trick, or have I unearthed something?

How to sudo/su specific files?

Is it possible to specify specific files to be installed as sudo, but still have all the file references relative to the current user's homedir?

Allow a common repo as an argument to fresh-options

As the fresh ecosystem grows we may source a lot more (trusted?) upstream files.
Perhaps we might consider supporting a common repository target as an option to fresh-options.

Example usage

# Default the repo for the following lines
fresh-options --repo=twe4ked/dotfiles --file=~/.zshrc --marker  
  fresh zsh/completion.zsh

  # Preserve access to local context by overriding repo to empty
  fresh zsh/my_completions.zsh --repo='' 

  # Honour the original syntax for different (non-local) repos
  fresh freshshell/fresh contrib/source-build.sh  

  # ...

  fresh zsh/prompt.zsh --ref=7192f1a
fresh-options 

Show relevant line from freshrc when erroring.

Right now we see an error like Could not find "pryrc" source file.
which does not actually mention which freshrc line is at fault.

We should probably also suggest fresh update and link to the source repo.

Better error messages

At the moment it's hard to tell if a command fails.

Idea at the moment is to simply make the existing success and error messages green and red respectively.

Concaternation is partially broken.

When concaternating files, fresh makes a assumption that the file's basename is unique.

Therefore, when I use something similar to this:

fresh config/newsbeuter/config --file=~/.config/newsbeuter/config
fresh config/ncmpcpp/config --file=~/.ncmpcpp/config

The two files are merged, as they both have the basename 'config'.

Remote sources

Add ability to pull remote files from GitHub.

# ~/.freshrc
fresh jasoncodes/dotfiles aliases/git
fresh twe4ked/dotfiles aliases/ruby

Clean dead links and repos

fresh clean
  1. Scan home directory and ~/bin for dead symlinks into ~/.fresh/build and remove them.
  2. Remove repos from ~/.fresh/source which are no longer referenced by ~/.freshrc.

Support bin files

# ~/.freshrc
fresh jasoncodes/scripts sedmv --bin # ~/bin/sedmv
fresh jasoncodes/scripts gemdiff --bin=~/bin/diff-gems
fresh jasoncodes/fresh bin/fresh --bin

Extension on #3.

Support config files

# ~/.freshrc
fresh jasoncodes/dotfiles ackrc --file # ~/.ackrc
fresh twe4ked/dotfiles lib/tmux.conf --file=~/.tmux.conf

Non-standard file permissions

Hi, I'm enjoying freshening up my dotfiles!

I want to put my .msmtprc into my dotfiles repo.

That's ok, but then they end up in ~/.fresh/build/ as -r--r--r-- and msmtp complains that the config file must have no more than user read/write permissions. Not a Git expert, perhaps there is a way to specify this in git, though not all file systems support it -- anyway the only think I've seen is using git hooks to execute chmod. What would you recommend?
Thanks

Mark

Command line options

fresh --help

fresh # install
fresh install
fresh update # update all source repos

Clone personal dotfiles when installing fresh

# from the #freshshell IRC.
[07:37:36] @jasoncodes: install script idea: set an environment variable for install.sh to do the clone for you
[07:38:27] @jasoncodes: DOTFILES=jasoncodes/dotfiles bash -c "`curl -sL get.freshshell.com`"

Thinking the variable should be less generic. Perhaps FRESH_LOCAL_SOURCE.

The idea is so you can run a single fresh install line to install your entire config.

Allow other freshrc files to be sourced in freshrc files.

# .freshrc
fresh twe4ked/dotfiles fresh/zsh-syntax-highlighting.freshrc --freshrc

…could be used to pull in this zsh syntax highlighting freshrc:

# fresh/zsh-syntax-highlighting.freshrc
fresh zsh-users/zsh-syntax-highlighting zsh-syntax-highlighting.zsh --file=vendor/zsh-syntax-highlighting.zsh
fresh zsh-users/zsh-syntax-highlighting highlighters/main/main-highlighter.zsh --file=vendor/highlighters/main/main-highlighter.zsh
fresh zsh-users/zsh-syntax-highlighting highlighters/brackets/brackets-highlighter.zsh --file=vendor/highlighters/brackets/brackets-highlighter.zsh
fresh zsh/zsh-syntax-highlighting.zsh

fresh will resolve local files (fresh zsh/zsh-syntax-highlighting.zsh) based on where the freshrc is sourced from.

The .freshrc extention would be optional.

🤘

Globs shouldn't match directories

If you have a fresh line with a glob:

fresh 'config/*' --file

With the following directory structure:

config/ackrc
config/pryrc
config/foo/bar

We get the following error:

cat: /Users/foo/.dotfiles/config/foo: Is a directory

We should also test this when using --ref.

Test: it_should_not_recurse_into_subdirectories.

Improve `runFresh` test helper to dry up the tests

To DRY up the following pattern in the tests:

  # ...
  bin/fresh clean > "$SANDBOX_PATH/out.log" 2> "$SANDBOX_PATH/err.log"
  assertTrue 'successfully cleans' $?

  assertFileMatches $SANDBOX_PATH/out.log <<EOF
Removing ~/.dead
Removing ~/bin/dead
EOF
  assertFileMatches $SANDBOX_PATH/err.log <<EOF
EOF
  # ...

Allow specifying a destination directory for files

Allow:

fresh vim/colors/bclear_custom.vim      --file=~/.vim/colors/bclear_custom.vim
fresh vim/colors/jellybeans_custom.vim  --file=~/.vim/colors/jellybeans_custom.vim
fresh vim/colors/solarized_custom.vim   --file=~/.vim/colors/solarized_custom.vim

To be:

fresh 'vim/colors/*'   --file=~/.vim/colors/

Copy files to build/ without symlinking

freshrc:

fresh zsh-users/zsh-syntax-highlighting zsh-syntax-highlighting.zsh --file=vendor/zsh-syntax-highlighting.zsh
fresh zsh-users/zsh-syntax-highlighting highlighters/brackets/brackets-highlighter.zsh --file=vendor/highlighters/brackets/brackets-highlighter.zsh

Copies brackets-highlighter.zsh from zsh-users/zsh-syntax-highlighting into ~/.fresh/build/vendor/highlighters/brackets/brackets-highlighter.zsh.

zshrc:

source "$FRESH_BUILD_PATH/vendor/zsh-syntax-highlighting.zsh"

Warn the user if they aren't managing fresh with fresh

$FRESH_PATH/build/bin/fresh not existing after building probably means the user accidentally omitted Fresh from their freshrc file. We should probably warn them about this and possibly provide resolution instructions.

Ideally we should check during build before we move build.new into place. This will prevent the user ending up in an state where fresh is unavailable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.