I wanted to make an alias turn caps lock off:python -c 'from ctypes import *; X11 = cdll.LoadLibrary(libX11.so.6); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)'I wrote this into my .zshrc:alias caps='python -c 'from ctypes import *; X11 = cdll.LoadLibrary(libX11.so.6); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)' 'But it seems that the problem is that I have ' in the command (so it make an alias to a part of it).I tried to use:alias caps= python -c 'from ctypes import *; X11 = cdll.LoadLibrary(libX11.so.6); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)' to see if something changed and I get python's sintax error.So how can I make an alias to a one-liner with ' inside?
How to alias a command with '
zsh;quoting;alias
You need to escape the double quotes in the python script:alias caps=python -c 'from ctypes import *; X11 = cdll.LoadLibrary(\libX11.so.6\); display = X11.XOpenDisplay(None); X11.XkbLockModifiers(display, c_uint(0x0100), c_uint(2), c_uint(0)); X11.XCloseDisplay(display)' Of course, you could also save that as a python script, and thenalias caps='path/to/script.py' 