Last active
May 12, 2025 17:02
-
-
Save z-a-f/b7337e4499c7f59cf8f7d3065543fac8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function cursor() { | |
| # Runs cursor instance | |
| # If ran with one of the arguments being "@some-word", will load an isolated | |
| # environment under *.PROFILE_SOME-WORD. | |
| # The environment can also be set using $CURSOR_PROFILE | |
| local CURSOR_PROFILE="${CURSOR_PROFILE-HOME}" | |
| local CATCH_TOKEN="@" | |
| local new_args=() | |
| local DISOWN=1 | |
| # See if arguments have a profile | |
| for arg in "${@}"; do | |
| if [[ "${arg}" == ${CATCH_TOKEN}* ]]; then | |
| CURSOR_PROFILE="${arg:1}" | |
| if [[ -z "${CURSOR_PROFILE}" ]]; then | |
| echo "Cannot use '@' argument without a name" | |
| return 2 | |
| fi | |
| elif [[ "${arg}" == "--no-disown" ]]; then | |
| DISOWN=0 | |
| else | |
| new_args+=("$arg") | |
| fi | |
| done | |
| set -- "${new_args[@]}" | |
| # Attempt setting the profile to uppercase | |
| CURSOR_PROFILE=$(echo "${CURSOR_PROFILE}" | awk '{print toupper($0)}') | |
| if [[ -z ${CURSOR_PROFILE} ]]; then | |
| ${CURSOR_BASE_PATH} --no-sandbox "${@}" > /dev/null 2>&1 & | |
| else | |
| # We will stick to the same structure, as if it was running from HOME | |
| # We don't wanna use full portable mode -- the goal is to have multiple | |
| # profiles, not multiple versions. | |
| # | |
| # If needed, create a hard link to $CURSOR_BASE_PATH (`ln $CURSOR_BASE_PATH mycursor`), | |
| # and create a portable home for it (`mkdir -p mycursor.home/.config`) | |
| local CURSOR_USER_HOME="${CURSOR_BASE_PATH}.PROFILE_${CURSOR_PROFILE}" | |
| local CURSOR_USER_DATA_DIR="${CURSOR_USER_HOME}/.config/Cursor" | |
| local CURSOR_USER_EXTENSIONS_DIR="${CURSOR_USER_HOME}/.cursor/extensions" | |
| mkdir -p ${CURSOR_USER_DATA_DIR} ${CURSOR_USER_EXTENSIONS_DIR} > /dev/null | |
| env CURSOR_PROFILE="${CURSOR_PROFILE}" ${CURSOR_BASE_PATH} \ | |
| --user-data-dir ${CURSOR_USER_DATA_DIR} \ | |
| --extensions-dir ${CURSOR_USER_EXTENSIONS_DIR} \ | |
| --profile ${CURSOR_PROFILE} \ | |
| --no-sandbox "${@}" \ | |
| > /dev/null 2>&1 & | |
| fi | |
| if [[ ! ${DISOWN} -eq 0 ]]; then | |
| # This is for debugging. One can "fg" to get the cursor process. | |
| disown | |
| fi | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # set -x | |
| # If you come from bash you might have to change your $PATH. | |
| # export PATH=$HOME/bin:/usr/local/bin:$PATH | |
| ## Key bindings | |
| bindkey "^[[1;5C" forward-word | |
| bindkey "^[[1;5D" backward-word | |
| ## Local paths | |
| USER_BIN="${HOME}/bin" | |
| LOCAL_USER_BIN="${HOME}/.local/bin" | |
| export PATH="${USER_BIN}${PATH:+:${PATH}}" | |
| export PATH="${LOCAL_USER_BIN}${PATH:+:${PATH}}" | |
| export XDG_CONFIG_HOME="${HOME}/.config" | |
| ## Custom paths | |
| fpath+=~/.zfunc | |
| autoload -U compinit; compinit | |
| zstyle ':completion:*' menu select | |
| ## PET setup | |
| function prev() { | |
| PREV=$(fc -lrn | head -n 1) | |
| sh -c "pet new `printf %q "$PREV"`" | |
| } | |
| function pet-select() { | |
| BUFFER=$(pet search --query "$LBUFFER") | |
| CURSOR=$#BUFFER | |
| zle redisplay | |
| } | |
| zle -N pet-select | |
| stty -ixon | |
| bindkey '^s' pet-select | |
| export FZF_CTRL_R_OPTS=" | |
| --reverse | |
| --cycle | |
| --info=right | |
| --color header:italic | |
| --header 'alt+s (pet new)' | |
| --preview 'echo {}' --preview-window down:3:hidden:wrap | |
| --bind '?:toggle-preview' | |
| --bind 'alt-s:execute(pet new --tag {2..})+abort'" | |
| ################################################################################ | |
| ## Oh My Zsh ## | |
| # Path to your oh-my-zsh installation. | |
| # export ZSH="/home/takeshi/.oh-my-zsh" | |
| # Set name of the theme to load --- if set to "random", it will | |
| # load a random theme each time oh-my-zsh is loaded, in which case, | |
| # to know which specific one was loaded, run: echo $RANDOM_THEME | |
| # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes | |
| # ZSH_THEME="zaf" | |
| # Set list of themes to pick from when loading at random | |
| # Setting this variable when ZSH_THEME=random will cause zsh to load | |
| # a theme from this variable instead of looking in $ZSH/themes/ | |
| # If set to an empty array, this variable will have no effect. | |
| # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) | |
| # Uncomment the following line to use case-sensitive completion. | |
| # CASE_SENSITIVE="true" | |
| # Uncomment the following line to use hyphen-insensitive completion. | |
| # Case-sensitive completion must be off. _ and - will be interchangeable. | |
| # HYPHEN_INSENSITIVE="true" | |
| # Uncomment the following line to disable bi-weekly auto-update checks. | |
| # DISABLE_AUTO_UPDATE="true" | |
| # Uncomment the following line to automatically update without prompting. | |
| # DISABLE_UPDATE_PROMPT="true" | |
| # Uncomment the following line to change how often to auto-update (in days). | |
| # export UPDATE_ZSH_DAYS=13 | |
| # Uncomment the following line if pasting URLs and other text is messed up. | |
| # DISABLE_MAGIC_FUNCTIONS="true" | |
| # Uncomment the following line to disable colors in ls. | |
| # DISABLE_LS_COLORS="true" | |
| # Uncomment the following line to disable auto-setting terminal title. | |
| # DISABLE_AUTO_TITLE="true" | |
| # Uncomment the following line to enable command auto-correction. | |
| # ENABLE_CORRECTION="true" | |
| # Uncomment the following line to display red dots whilst waiting for completion. | |
| # Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work) | |
| # See https://github.com/ohmyzsh/ohmyzsh/issues/5765 | |
| # COMPLETION_WAITING_DOTS="true" | |
| # Uncomment the following line if you want to disable marking untracked files | |
| # under VCS as dirty. This makes repository status check for large repositories | |
| # much, much faster. | |
| # DISABLE_UNTRACKED_FILES_DIRTY="true" | |
| # Uncomment the following line if you want to change the command execution time | |
| # stamp shown in the history command output. | |
| # You can set one of the optional three formats: | |
| # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" | |
| # or set a custom format using the strftime function format specifications, | |
| # see 'man strftime' for details. | |
| # HIST_STAMPS="mm/dd/yyyy" | |
| # History size | |
| HISTFILE=~/.zsh_history | |
| HISTSIZE=999999 | |
| SAVEHIST=$HISTSIZE | |
| # Would you like to use another custom folder than $ZSH/custom? | |
| # ZSH_CUSTOM=/path/to/new-custom-folder | |
| # Which plugins would you like to load? | |
| # Standard plugins can be found in $ZSH/plugins/ | |
| # Custom plugins may be added to $ZSH_CUSTOM/plugins/ | |
| # Example format: plugins=(rails git textmate ruby lighthouse) | |
| # Add wisely, as too many plugins slow down shell startup. | |
| # plugins=(git) | |
| # source $ZSH/oh-my-zsh.sh | |
| ## Oh My Zsh ## | |
| ################################################################################ | |
| ################################################################################ | |
| ## Oh My Posh ## | |
| # export OMP=${HOME}/.cache/oh-my-posh | |
| export OMP=${HOME}/bin/oh-my-posh | |
| OMP_THEME=${HOME}/dotfiles/.oh-my-posh-theme.omp.yaml | |
| eval "$(oh-my-posh init zsh --config ${OMP_THEME})" | |
| ## Oh My Posh ## | |
| ################################################################################ | |
| # User configuration | |
| # export MANPATH="/usr/local/man:$MANPATH" | |
| # You may need to manually set your language environment | |
| # export LANG=en_US.UTF-8 | |
| # Compilation flags | |
| # export ARCHFLAGS="-arch x86_64" | |
| # Set personal aliases, overriding those provided by oh-my-zsh libs, | |
| # plugins, and themes. Aliases can be placed here, though oh-my-zsh | |
| # users are encouraged to define aliases within the ZSH_CUSTOM folder. | |
| # For a full list of active aliases, run `alias`. | |
| # | |
| # Example aliases | |
| # alias zshconfig="mate ~/.zshrc" | |
| # alias ohmyzsh="mate ~/.oh-my-zsh" | |
| # System aliases | |
| alias abspath='which abspath || python -c "import os,sys; print os.path.abspath(sys.argv[1])"' # This is just a hack | |
| alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' | |
| alias cp='cp -rvi' | |
| alias cppcheck='cppcheck --enable=all --inconclusive --std=posix --language=c++' | |
| alias dog='highlight -O xterm256 --failsafe' | |
| alias du='du -ch -d 1' | |
| alias ekill="emacsclient -e '(kill-emacs)'" | |
| alias em='emacs -nw' # No X11 windows | |
| alias emacsd='emacs --daemon' | |
| alias emax='emacsclient -t' | |
| alias eqq='emacs -nw -Q' # No config and no X11 | |
| alias ff="grep -rnw '.' -e " | |
| alias kotl="kotlinc-jfvm" | |
| alias ls='ls -GFh --color' | |
| alias ll='ls -GFhal --color' | |
| alias mkdir='mkdir -pv' | |
| alias mv="mv -i" | |
| alias nano='nano -c' | |
| alias pig='pygmentize -g' | |
| alias rm='rm -vi' | |
| # alias todo='xargs -I{} git grep -nEIi "TODO\s*\({}\)" <<<' | |
| alias todo='xargs -I{} git grep -EIi "TODO\({}\)" <<<' | |
| alias tw='open -a /Applications/TextWrangler.app' | |
| alias valgrind='valgrind --leak-check=full --tool=memcheck' | |
| # Third-party stuff | |
| alias gclogin='gcloud auth application-default login' | |
| alias gconfigs='gcloud config configurations' | |
| alias pykernel='xargs -I{} python -m ipykernel install --user --name {} --display-name "Python \({}\)" <<< ' | |
| # # Per-directory sources | |
| # function cd() { | |
| # # Check if directory exists before attempting to cd | |
| # if [[ $# -eq 0 ]]; then | |
| # builtin cd || return 1 | |
| # else | |
| # builtin cd "$@" || return 1 | |
| # fi | |
| # # Only proceed with sourcing if cd was successful | |
| # if [[ $? -eq 0 ]]; then | |
| # [[ -f .aliases ]] && source "./.aliases" | |
| # [[ -f .functions ]] && source "./.functions" | |
| # fi | |
| # } | |
| # Custom paths | |
| # The next line updates PATH for the Google Cloud SDK. | |
| if [ -f '/usr/local/google-cloud-sdk/path.zsh.inc' ]; then . '/usr/local/google-cloud-sdk/path.zsh.inc'; fi | |
| # The next line enables shell command completion for gcloud. | |
| if [ -f '/usr/local/google-cloud-sdk/completion.zsh.inc' ]; then . '/usr/local/google-cloud-sdk/completion.zsh.inc'; fi | |
| export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | |
| [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm | |
| [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion | |
| ################################################################################ | |
| # Custom global variables. Make sure there is an explanation why we use global! | |
| ################################################################################ | |
| # Java | |
| export JAVA_HOME="/usr/lib/jvm/java-21-openjdk-amd64" | |
| export PATH="${JAVA_HOME}/bin${PATH:+:${PATH}}" | |
| # `nvidia-smi` uses PCI-E id when enumerating the GPUs, however, when using | |
| # CUDA_VISIBLE_DEVICES, we need to obey the CUDA_DEVICE_ORDER. Setting it to | |
| # fastest first will preven the change in the PCI-E bus id from using differnt | |
| # GPU. Available options: FASTEST_FIRST and PCI_BUS_ID | |
| export CUDA_DEVICE_ORDER=FASTEST_FIRST | |
| # >>> mamba initialize >>> | |
| # !! Contents within this block are managed by 'mamba init' !! | |
| export MAMBA_EXE="${USER_BIN}/micromamba"; | |
| export MAMBA_ROOT_PREFIX="${HOME}/micromamba"; | |
| __mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)" | |
| if [ $? -eq 0 ]; then | |
| eval "$__mamba_setup" | |
| else | |
| alias micromamba="$MAMBA_EXE" # Fallback on help from mamba activate | |
| fi | |
| unset __mamba_setup | |
| # <<< mamba initialize <<< | |
| alias micro='micromamba' | |
| alias conda='micromamba' | |
| ################################################################################ | |
| # Custom executables | |
| ################################################################################ | |
| # Browser | |
| export BROWSER="firefox" | |
| # DirEnv | |
| type direnv >/dev/null 2>&1 && eval "$(direnv hook zsh)" | |
| # Python CUDA check | |
| # Lottie -- this is optional, only used for animations and vector graphics | |
| # LOTTIE_PATH="${HOME}/Desktop/Git/python-lottie" | |
| # LOTTIE_URL="https://gitlab.com/mattbas/python-lottie" | |
| # if [ ! -d "${LOTTIE_PATH}" ]; then | |
| # git clone "${LOTTIE_URL}" "${LOTTIE_PATH}" | |
| # fi | |
| # export PATH="${LOTTIE_PATH}/bin${PATH:+:${PATH}}" | |
| # Cursor installation | |
| export CURSOR_BASE_NAME="_cursor.AppImage" | |
| export CURSOR_BASE_DIR="${LOCAL_USER_BIN}" | |
| export CURSOR_BASE_PATH="${CURSOR_BASE_DIR}/${CURSOR_BASE_NAME}" | |
| CURSOR_DOWNLOAD=${CURSOR_DOWNLOAD:-0} | |
| if [[ ! -f ${CURSOR_BASE_PATH} && ${CURSOR_DOWNLOAD} ]]; then | |
| echo "Downloading Cursor AppImage..." | |
| local CURSOR_URL="https://downloader.cursor.sh/linux/appImage/x64" | |
| if ! curl -L $CURSOR_URL -o $CURSOR_BASE_PATH; then | |
| echo "Failed to download Cursor AppImage. Please check your internet connection." | |
| return 1 | |
| fi | |
| chmod +x $CURSOR_BASE_PATH | |
| fi | |
| function cursor() { | |
| # Runs cursor instance | |
| # If ran with one of the arguments being "@some-word", will load an isolated | |
| # environment under *.PROFILE_SOME-WORD. | |
| # The environment can also be set using $CURSOR_PROFILE | |
| local CURSOR_PROFILE="${CURSOR_PROFILE-HOME}" | |
| local CATCH_TOKEN="@" | |
| local new_args=() | |
| local DISOWN=1 | |
| # See if arguments have a profile | |
| for arg in "${@}"; do | |
| if [[ "${arg}" == ${CATCH_TOKEN}* ]]; then | |
| CURSOR_PROFILE="${arg:1}" | |
| if [[ -z "${CURSOR_PROFILE}" ]]; then | |
| echo "Cannot use '@' argument without a name" | |
| return 2 | |
| fi | |
| elif [[ "${arg}" == "--no-disown" ]]; then | |
| DISOWN=0 | |
| else | |
| new_args+=("$arg") | |
| fi | |
| done | |
| set -- "${new_args[@]}" | |
| # Attempt setting the profile to uppercase | |
| CURSOR_PROFILE=$(echo "${CURSOR_PROFILE}" | awk '{print toupper($0)}') | |
| if [[ -z ${CURSOR_PROFILE} ]]; then | |
| ${CURSOR_BASE_PATH} --no-sandbox "${@}" > /dev/null 2>&1 & | |
| else | |
| # We will stick to the same structure, as if it was running from HOME | |
| # We don't wanna use full portable mode -- the goal is to have multiple | |
| # profiles, not multiple versions. | |
| # | |
| # If needed, create a hard link to $CURSOR_BASE_PATH (`ln $CURSOR_BASE_PATH mycursor`), | |
| # and create a portable home for it (`mkdir -p mycursor.home/.config`) | |
| local CURSOR_USER_HOME="${CURSOR_BASE_PATH}.PROFILE_${CURSOR_PROFILE}" | |
| local CURSOR_USER_DATA_DIR="${CURSOR_USER_HOME}/.config/Cursor" | |
| local CURSOR_USER_EXTENSIONS_DIR="${CURSOR_USER_HOME}/.cursor/extensions" | |
| mkdir -p ${CURSOR_USER_DATA_DIR} ${CURSOR_USER_EXTENSIONS_DIR} > /dev/null | |
| env CURSOR_PROFILE="${CURSOR_PROFILE}" ${CURSOR_BASE_PATH} \ | |
| --user-data-dir ${CURSOR_USER_DATA_DIR} \ | |
| --extensions-dir ${CURSOR_USER_EXTENSIONS_DIR} \ | |
| --profile ${CURSOR_PROFILE} \ | |
| --no-sandbox "${@}" \ | |
| > /dev/null 2>&1 & | |
| fi | |
| if [[ ! ${DISOWN} -eq 0 ]]; then | |
| # This is for debugging. One can "fg" to get the cursor process. | |
| disown | |
| fi | |
| } | |
| # Preferred editor for local and remote sessions | |
| if [[ -n $SSH_CONNECTION ]]; then | |
| export EDITOR='vim' | |
| elif [[ -n $CURSOR_PROFILE ]]; then | |
| export EDITOR='cursor --wait' | |
| else | |
| export EDITOR='code --wait' | |
| fi | |
| export VISUAL="$EDITOR" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cursor installation | |
| export CURSOR_BASE_NAME="_cursor.AppImage" | |
| export CURSOR_BASE_DIR="${LOCAL_USER_BIN}" | |
| export CURSOR_BASE_PATH="${CURSOR_BASE_DIR}/${CURSOR_BASE_NAME}" | |
| CURSOR_DOWNLOAD=${CURSOR_DOWNLOAD:-0} | |
| if [[ ! -f ${CURSOR_BASE_PATH} && ${CURSOR_DOWNLOAD} ]]; then | |
| echo "Downloading Cursor AppImage..." | |
| local CURSOR_URL="https://downloader.cursor.sh/linux/appImage/x64" | |
| if ! curl -L $CURSOR_URL -o $CURSOR_BASE_PATH; then | |
| echo "Failed to download Cursor AppImage. Please check your internet connection." | |
| return 1 | |
| fi | |
| chmod +x $CURSOR_BASE_PATH | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # We don't install it manually -- just rename existing installation | |
| export CURSOR_BASE_DIR="/usr/local/bin" # We assume this is the path | |
| CURSOR_ORIGINAL_PATH="${CURSOR_BASE_DIR}/cursor" | |
| export CURSOR_BASE_NAME="_cursor" # This will be the new name | |
| export CURSOR_PASE_PATH="${CURSOR_BASE_DIR}/${CURSOR_BASE_NAME}" | |
| if [[ -f "${CURSOR_ORIGINAL_PATH}" ]]; then | |
| mv "${CURSOR_ORIGINAL_PATH}" "${CURSOR_BASE_PATH}" | |
| chmod +x ${CURSOR_BASE_PATH} | |
| fi | |
| if [[ ! -f "${CURSOR_BASE_PATH}" ]]; then | |
| # There is no cursor installed, and nothing is renamed | |
| echo "I don't see cursor executable under ${CURSOR_BASE_DIR}..." | |
| return 1 | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment