Git Product home page Git Product logo

clickup_command_line_timers's Introduction

ClickUp Timer Command Line Scripts

Start and Stop your ClickUp timers with a simple command. Use Git hooks to automatically add time to a timer as a successful commit is posted.
Click here to jump to the section on Git hooks

How to use the command line to start and stop a timer for a task...

  1. Fork or clone this repo.
  2. Save the clickup_scripts folder inside of the usr/local/bin directory (or similar depending on your OS)
  3. Copy the zsh_script into your ~/.zshrc file (or bash, fsh, etc. - depending on your system it may need to be adjusted slightly).
  4. Restart your terminal or the command source ~/.zshrc.

Now...

Look over the files in the clickup_scripts directory and update information as needed.
For example, you probably want to update the TEAM_ID, USER_ID, and API_KEY, though there may be other areas that you will want to customize (such as the api endpoints depending on your desired use).

To Start and Stop a Timer...

To start a timer:

Run the command cu start <tag> <note> from your terminal.
You should receive a message indicating whether the timer succesfully started, or whether an error was encountered.

To stop a timer:

Run the command cu stop <tag> <note> from your terminal.
You should receive a message indicating whether the timer succesfully stopped, or whether an error was encountered.

How To Create a Global Post-Commit Git Hook

Some initial notes before you dive in...

  • It is recommended to save the ruby script in /usr/local/bin/clickup_scripts/record_commit.rb to make it globally available.
  • The hook is defined in usr/local/Cellar/git/2.38.0/share/git-core/templates/hooks/post-commit (NOTE: this file should have no file extension)
  • Once you've completed all of these steps below, the record_commit script will run automatically every time you make a successful commit in any Git repository on your system.
  • The script was created to use commits that have commit messages appended with a special "task_id" to record time entries for work, but you can update the script to use it for whatever your needs are.

To set up the post-commit hook, which is a script that runs after a successful commit, you should locate the .git/hooks directory on your system.
On Linux and macOS, this directory is typically located at ~/.config/git/hooks. On Windows, it is located at C:\Program Files\Git\mingw64\share\git-core\templates\hooks

Create a new file called post-commit in this directory.

The post-commit script should contain the following line, which runs the script you just created and passes the commit message as an argument to the script.:
ruby /usr/local/bin/clickup_scripts/record_commit.rb "$(git log -1 --pretty=%B)"

This script uses the git log command to get the commit message, and it passes the commit message to the record_commit.rb script as an argument.

It is important to note that this directory may not exist by default, so you may need to create it if it does not exist.
The directions here set it up as a global hook, which will be applied to every repository on your machine. You can find the global hooks in your $(prefix)/share/git-core/templates/hooks directory. The actual directory may vary depending on your environment.
If yours is different, you can start to locate the directory by running the following command:
git --exec-path -or- find template/hooks.

Please note that if you have already created a post-commit hook in a specific repository, the global one will not override it.

You should make sure that the post-commit script has permission to execute by running the following command once the above steps are complete:
chmod +x post-commit

NOTE: Make sure you run the chmod +x command for any additional files you created in the script (such as the .txt files).

Re-initialize git in the repository you want to use the hook in.
git init

NOTE: Keep in mind that if you change the script, you need to repeat these steps again to propagate the changes.

Feedback? Suggestions? Questions? Praise?

clickup_command_line_timers's People

Contributors

brennacodes avatar

Stargazers

 avatar

Watchers

 avatar

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.