Skip to content

Instantly share code, notes, and snippets.

@penn201500
penn201500 / switch.el
Last active December 13, 2021 13:04 — forked from celadevra/switch.el
Sane switching of input methods when using evil-mode in Emacs on OSX;change some conf for qwerty keyboard, and default-im keyboard changed to be self-conf.
;; switch to english input method when switching to normal mode
;; and switch back when entering insert/replace modes
;; need external script support, currently mac-only
(defvar default-im "org.unknown.keylayout.layoutformc" "Default ascii-only input method")
(defvar prev-im (substring (shell-command-to-string "/usr/local/bin/im-select") 0 -1)
"IM that I use when starting Emacs and exiting insert mode")
(defun im-use-english ()
"Switch to english input method on a Mac. im-select is a tool
provided at https://github.com/daipeihust/im-select"
#!/bin/sh
#
set -ex
TEMP_DIR="$(mktemp -d -t XXXX)"
# cleanup
trap 'RESULT=$?; rm -rf "$TEMP_DIR" ; exit $RESULT' INT TERM EXIT QUIT
OLD_PWD="$PWD"
cd "$TEMP_DIR"
@penn201500
penn201500 / .ripgreprc
Last active September 13, 2019 03:37 — forked from asrivascrealytee/.ripgreprc
ripgreprc
#First, you need to set the RIPGREP_CONFIG_PATH environment variable to the file path of your config file
# export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc
# Don't let ripgrep vomit really long lines to my terminal.
--max-columns=150
--max-columns-preview
# Add my 'web' type.
--type-add
web:*.{html,css,js}*
@penn201500
penn201500 / iterm2.zsh
Created October 24, 2019 08:52 — forked from wadey/iterm2.zsh
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"
@penn201500
penn201500 / profile.md
Created December 10, 2019 05:51 — forked from ezekg/profile.md
iTerm key bindings

Open the iTerm preferences ⌘+, and navigate to the Profiles tab (the Keys tab can be used, but adding keybinding to your profile allows you to save your profile and sync it to multiple computers) and keys sub-tab and enter the following:

Delete all characters left of the cursor

⌘+←Delete Send Hex Codes:

  • 0x18 0x7f – Less compatible, doesn't work in node and won't work in zsh by default, see below to fix zsh (bash/irb/pry should be fine), performs desired functionality when it does work.
  • 0x15 – More compatible, but typical functionality is to delete the entire line rather than just the characters to the left of the cursor.

Delete all characters right of the cursor

⌘+fn+←Delete or ⌘+Delete→ Send Hex Codes:

  • 0x0b
@penn201500
penn201500 / proj2ram
Created March 9, 2020 15:14 — forked from redguardtoo/proj2ram
script to copy project to tmpfs
#!/bin/sh
if [ -z "$1" ];then
echo "Usage:"
echo " proj2ram proj-name"
echo " proj2ram restore proj-name"
exit 1
fi
@penn201500
penn201500 / mount-ram.sh
Created March 10, 2020 15:55 — forked from koshigoe/mount-ram.sh
Like tmpfs in Mac OSX
#!/bin/sh
# This program has two feature.
#
# 1. Create a disk image on RAM.
# 2. Mount that disk image.
#
# Usage:
# $0 <dir> <size>
#
@penn201500
penn201500 / JiraOmniFocus.py
Created March 13, 2020 13:42 — forked from adammorris/JiraOmniFocus.py
Example snippet on how to sync from JIRA to OmniFocus.
"""
Example snippet on how to sync from JIRA to omnifocus.
The main function is OmniFocus.sync_jira_to_omnifocus().
OmniFocus.process_jira_data() is customized to filter projects based on my own needs and will need updating.
"""
from applescript import AppleScript, ScriptError
from datetime import datetime
from json import JSONDecoder
from logging import getLogger
@penn201500
penn201500 / casesafe.sh
Created March 18, 2020 15:14 — forked from scottsb/casesafe.sh
Create and manage a case-sensitive disk-image on macOS (OS X).
#!/bin/bash
# ---------------------------------------------------------
# Customizable Settings
# ---------------------------------------------------------
MOUNT_POINT="${CASE_SAFE_MOUNT_POINT:-${HOME}/casesafe}"
VOLUME_PATH="${CASE_SAFE_VOLUME_PATH:-${HOME}/.casesafe.dmg.sparseimage}"
VOLUME_NAME="${CASE_SAFE_VOLUME_NAME:-casesafe}"
VOLUME_SIZE="${CASE_SAFE_VOLUME_SIZE:-60g}"
@penn201500
penn201500 / backupRamDisk.sh
Created March 18, 2020 15:45 — forked from enihsyou/backupRamDisk.sh
Create a RamDisk backup DMG image on macOS, detail in Chinese 中文: https://enihsyou.com/2019/02/04/48
#!/usr/bin/env bash
DISKNAME=${1-RAM}
IMAGE_LOCATION=${2-"/Users/enihsyou/Library/RAM.dmg"}
DISK_LOCATION=/Volumes/${DISKNAME}
sudo hdiutil create -srcfolder $DISK_LOCATION $IMAGE_LOCATION -ov
sudo chown enihsyou $IMAGE_LOCATION