Skip to content

Instantly share code, notes, and snippets.

View derhasi's full-sized avatar
💚
Life is green!

Johannes Haseitl derhasi

💚
Life is green!
  • Nuremberg, Germany
  • 14:24 (UTC +01:00)
View GitHub Profile
@ssp
ssp / git-extract-file.markdown
Created January 23, 2012 13:21
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

@wadey
wadey / iterm2.zsh
Last active January 13, 2025 14:26
Change iTerm2 tab color when using SSH
# Usage:
# source iterm2.zsh
# iTerm2 tab color commands
# https://iterm2.com/documentation-escape-codes.html
if [[ -n "$ITERM_SESSION_ID" ]]; then
tab-color() {
echo -ne "\033]6;1;bg;red;brightness;$1\a"
echo -ne "\033]6;1;bg;green;brightness;$2\a"
@persand
persand / Drupal Pathauto i18n-ascii.txt – extended version
Created July 4, 2010 15:50
Modified i18n-ascii.txt for Drupal Pathauto module
; More thorough than the original. Use this with Pathauto 6.x-1.x.
; Here are the modifications:
; 1. Ü, Ä and Ö characters converted to u, a and o instead of ue, ae and oe.
; 2. Common typographic punctation (dashes, quotation marks and more) added at the bottom.
; global transliteration
[default]
À = "A"
Á = "A"
 = "A"