All Projects → zsh-users → Zsh Apple Touchbar

zsh-users / Zsh Apple Touchbar

Licence: mit
Make your touchbar more powerful.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Zsh Apple Touchbar

Zsh Iterm Touchbar
Display feedback of terminal in the 🍏 Touchbar
Stars: ✭ 632 (+142.15%)
Mutual labels:  zsh, iterm2, touchbar
Z.lua
⚡ A new cd command that helps you navigate faster by learning your habits.
Stars: ✭ 2,164 (+729.12%)
Mutual labels:  zsh, zsh-plugin
Dotfiles
📍 My dotfiles for macOS using Fish/Zsh, Neovim, and Tmux
Stars: ✭ 151 (-42.15%)
Mutual labels:  zsh, iterm2
ranger-autojump
The combined magic of autojump, ranger and zsh
Stars: ✭ 59 (-77.39%)
Mutual labels:  zsh, zsh-plugin
git-prompt.zsh
A fast, customizable, pure-shell, asynchronous Git prompt for Zsh
Stars: ✭ 139 (-46.74%)
Mutual labels:  zsh, zsh-plugin
History Sync
An oh-my-zsh plugin for GPG encrypted internet synchronised Zsh history, with Git.
Stars: ✭ 135 (-48.28%)
Mutual labels:  zsh, zsh-plugin
gitignore.plugin.zsh
ZSH plugin for creating .gitignore files.
Stars: ✭ 44 (-83.14%)
Mutual labels:  zsh, zsh-plugin
Forgit
💤 A utility tool powered by fzf for using git interactively.
Stars: ✭ 1,823 (+598.47%)
Mutual labels:  zsh, zsh-plugin
zsh-ssh-agent
Ssh-agent management for zsh
Stars: ✭ 19 (-92.72%)
Mutual labels:  zsh, zsh-plugin
tipz
Gives you helpful hints when you execute a command for which you have an alias defined
Stars: ✭ 24 (-90.8%)
Mutual labels:  zsh, zsh-plugin
aterminal
🎉 An oh-my-zsh plugin for show platform versions
Stars: ✭ 31 (-88.12%)
Mutual labels:  zsh, zsh-plugin
Autoenv
Autoenv for zsh
Stars: ✭ 131 (-49.81%)
Mutual labels:  zsh, zsh-plugin
Zpm
ZPM — Zsh Plugin Manager
Stars: ✭ 112 (-57.09%)
Mutual labels:  zsh, zsh-plugin
Quiver
Quiver is the tool to manage all of your tools for bug bounty hunting and penetration testing.
Stars: ✭ 140 (-46.36%)
Mutual labels:  zsh, zsh-plugin
Zsh Abbr
The zsh manager for auto-expanding abbreviations, inspired by fish shell.
Stars: ✭ 109 (-58.24%)
Mutual labels:  zsh, zsh-plugin
Zsh Vi Mode
💻 A better and friendly vi(vim) mode plugin for ZSH.
Stars: ✭ 181 (-30.65%)
Mutual labels:  zsh, zsh-plugin
zhooks
Display Zsh hook functions and arrays
Stars: ✭ 36 (-86.21%)
Mutual labels:  zsh, zsh-plugin
Zsh Snap
⚡️ Znap! A fast & light-weight plugin manager & Git repo manager for Zsh.
Stars: ✭ 98 (-62.45%)
Mutual labels:  zsh, zsh-plugin
Zsh Nvm
Zsh plugin for installing, updating and loading nvm
Stars: ✭ 1,670 (+539.85%)
Mutual labels:  zsh, zsh-plugin
zsh-titles
Terminal/tmux titles based on current location and task
Stars: ✭ 46 (-82.38%)
Mutual labels:  zsh, zsh-plugin

zsh-apple-touchbar

Make your touchbar more powerful.

preview

Requirements

  • iTerm2 3.1 or later
  • zsh
  • ruby 2.3.4 or later (only if you want automatic generation)

In iterm2: Go to View -> Customize Tool Bar... and drag & drop the Fn module

Installation

Manual

  1. Clone this repository somewhere on your machine. This guide will assume ~/.zsh/zsh-apple-touchbar.
git clone https://github.com/zsh-users/zsh-apple-touchbar ~/.zsh/zsh-apple-touchbar
  1. Add the following to your .zshrc:
source ~/.zsh/zsh-apple-touchbar/zsh-apple-touchbar.zsh
  1. Start a new terminal session.

Oh My Zsh

  1. Clone this repository into $ZSH_CUSTOM/plugins (by default ~/.oh-my-zsh/custom/plugins)
git clone https://github.com/zsh-users/zsh-apple-touchbar $ZSH_CUSTOM/plugins/zsh-apple-touchbar
  1. Add the plugin to the list of plugins for Oh My Zsh to load:
plugins=(zsh-apple-touchbar)
  1. Start a new terminal session.

Customization

Automatic

You can define simple commands for FN keys in config.yml file.

Structure

File should have two base keys:

  1. default_view - default view to show.
  2. views - list of defined views.

views section contains views you want to show. Key is a view name.

Under view name key you should define next keys:

  1. text - text that will show on touchbar key.
  2. command or view - command means executing some command that under is this key and view means show view that is under this key
  3. back - under this key should be a view name that will be shown after executing some command.

Example

default_view: first
views:
  first:
    1:
      text: 👉 pwd
      command: pwd |tr -d "\\n" |pbcopy
    2:
      text: second view
      view: second
    3:
      text: third view
      view: third
  second:
    1:
      text: 👈 back
      view: first
    2:
      text: current path
      command: pwd
    back: first
  third:
    1:
      text: 👈 back
      view: first
    2:
      text: ls
      command: ls -la

For generating view from config.yml file go to its folder:

cd $ZSH_CUSTOM/plugins/zsh-apple-touchbar

and run generate.rb file:

ruby generate.rb

Custom

If you need more complicated logic you can rewrite zsh-apple-touchbar.zsh file on your own.

View functions

For each view you need to define separate function that will contain keys creation. E.G.

function first_view() {
  remove_and_unbind_keys

  set_state 'first'

  create_key 1 '👉 pwd' 'pwd |tr -d "\\n" |pbcopy' '-s'
  create_key 2 'second view' 'second_view'
}

function second_view() {
  remove_and_unbind_keys

  set_state 'second'

  create_key 1 '👈 back' 'first_view'
  create_key 2 'current path' 'pwd' '-s'

  set_state 'first'
}

In every function first, you need to remove and unbind old keys with remove_and_unbind_keys function.

Then you need to set a state (state variable define which view to show after reinitialization) with set_state function.

After that, you can create keys for this view with create_key function.

And after keys part you can set new state (if you want to show some view after executing key command).

Keys creation

Keys creates with create_key function

This function accept 4 arguments:

  1. number of key (from 1 to 12)
  2. key text
  3. command or view
  4. bind option (-s if third argument isn't a view, nothing if it is)

Init widgets

For calling views in main function you need to init widgets for every view function.

zle -N first
zle -N second

Main function

Here you need to define which view to show for every state.

precmd_apple_touchbar() {
  case $state in
    first) first_view ;;
    second) second_view ;;
  esac
}

Full example

source ${0:A:h}/functions.zsh

set_state 'first'

function first_view() {
  remove_and_unbind_keys

  set_state 'first'

  create_key 1 '👉 pwd' 'pwd |tr -d "\\n" |pbcopy' '-s'
  create_key 2 'second view' 'second_view'
}

function second_view() {
  remove_and_unbind_keys

  set_state 'second'

  create_key 1 '👈 back' 'first_view'
  create_key 2 'current path' 'pwd' '-s'

  set_state 'first'
}

zle -N first_view
zle -N second_view

precmd_apple_touchbar() {
  case $state in
    first) first_view ;;
    second) second_view ;;
  esac
}

autoload -Uz add-zsh-hook

add-zsh-hook precmd precmd_apple_touchbar

Contributing

If you have some proposals how to improve this boilerplate feel free to open issues and send pull requests!

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].