Skip to content

Instantly share code, notes, and snippets.

@skyline75489
Last active July 14, 2025 02:45
Show Gist options
  • Save skyline75489/d655aede4c729eff178a1c0bfd10f622 to your computer and use it in GitHub Desktop.
Save skyline75489/d655aede4c729eff178a1c0bfd10f622 to your computer and use it in GitHub Desktop.

Revisions

  1. skyline75489 revised this gist Dec 17, 2020. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    __wt_osc7 () {
    __wt_osc9_9 () {
    _win_path=$(wslpath -m $(pwd))
    printf "\033]7;file://%s/%s\033\\" "$HOSTNAME" "$_win_path"
    printf "\033]9;9;%s\033\\" "$_win_path"
    }

    [ -n "$BASH_VERSION" ] && [ -n "$WT_SESSION" ] && PROMPT_COMMAND="__wt_osc7"
    [ -n "$ZSH_VERSION" ] && [ -n "$WT_SESSION" ] && precmd_functions+=(__wt_osc7)
    [ -n "$BASH_VERSION" ] && [ -n "$WT_SESSION" ] && PROMPT_COMMAND="__wt_osc9_9"
    [ -n "$ZSH_VERSION" ] && [ -n "$WT_SESSION" ] && precmd_functions+=(__wt_osc9_9)

    true
  2. skyline75489 revised this gist Sep 22, 2020. 1 changed file with 1 addition and 7 deletions.
    8 changes: 1 addition & 7 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,6 @@
    __wt_osc7 () {
    # Windows Path
    if [[ "$(pwd)" =~ ^/mnt/* ]]; then
    _win_path=$(echo "$(pwd)" | sed -e "s/\/mnt\\/\([a-zA-Z]*\)\(.*\)/\1:\2/g")
    _win_path=$(wslpath -m $(pwd))
    printf "\033]7;file://%s/%s\033\\" "$HOSTNAME" "$_win_path"
    else
    # Linux Path
    printf "\033]7;file://%s/\\\\\\\\wsl$\\%s%s\033\\" "$HOSTNAME" "$WSL_DISTRO_NAME" "$(pwd)"
    fi
    }

    [ -n "$BASH_VERSION" ] && [ -n "$WT_SESSION" ] && PROMPT_COMMAND="__wt_osc7"
  3. skyline75489 revised this gist Sep 21, 2020. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,11 @@
    DIST="Ubuntu"

    __wt_osc7 () {
    # Windows Path
    if [[ "$(pwd)" =~ ^/mnt/* ]]; then
    _win_path=$(echo "$(pwd)" | sed -e "s/\/mnt\\/\([a-zA-Z]*\)\(.*\)/\1:\2/g")
    printf "\033]7;file://%s/%s\033\\" "$HOSTNAME" "$_win_path"
    else
    # Linux Path
    printf "\033]7;file://%s/\\\\\\\\wsl$\\%s%s\033\\" "$HOSTNAME" "$DIST" "$(pwd)"
    printf "\033]7;file://%s/\\\\\\\\wsl$\\%s%s\033\\" "$HOSTNAME" "$WSL_DISTRO_NAME" "$(pwd)"
    fi
    }

  4. skyline75489 revised this gist Sep 20, 2020. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -3,12 +3,11 @@ DIST="Ubuntu"
    __wt_osc7 () {
    # Windows Path
    if [[ "$(pwd)" =~ ^/mnt/* ]]; then
    # Change "/mnt/c/path" to "c:\path"
    _win_path=$(echo "$(pwd)" | sed -e "s/\/mnt\\/\([a-zA-Z]*\)\/\(.*\)/\1:\/\2/g")
    printf "\033]7;file://%s\033\\" "$_win_path"
    _win_path=$(echo "$(pwd)" | sed -e "s/\/mnt\\/\([a-zA-Z]*\)\(.*\)/\1:\2/g")
    printf "\033]7;file://%s/%s\033\\" "$HOSTNAME" "$_win_path"
    else
    # Linux Path
    printf "\033]7;file://\\\\\\\\wsl$\\%s%s\033\\" "$DIST" "$(pwd)"
    printf "\033]7;file://%s/\\\\\\\\wsl$\\%s%s\033\\" "$HOSTNAME" "$DIST" "$(pwd)"
    fi
    }

  5. skyline75489 revised this gist Sep 18, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion prompt.sh
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ DIST="Ubuntu"
    __wt_osc7 () {
    # Windows Path
    if [[ "$(pwd)" =~ ^/mnt/* ]]; then
    # Change "/mnt/c/x" to "C:\x"
    # Change "/mnt/c/path" to "c:\path"
    _win_path=$(echo "$(pwd)" | sed -e "s/\/mnt\\/\([a-zA-Z]*\)\/\(.*\)/\1:\/\2/g")
    printf "\033]7;file://%s\033\\" "$_win_path"
    else
  6. skyline75489 revised this gist Sep 18, 2020. No changes.
  7. skyline75489 revised this gist Sep 18, 2020. 1 changed file with 4 additions and 9 deletions.
    13 changes: 4 additions & 9 deletions prompt.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,9 @@
    DIST="Ubuntu"

    __vte_osc7 () {
    __wt_osc7 () {
    # Windows Path
    if [[ "$(pwd)" =~ ^/mnt/* ]]; then
    # Change "/mnt/c/x" to "C:\x"
    _win_path=$(echo "$(pwd)" | sed -e "s/\/mnt\\/\([a-zA-Z]*\)\/\(.*\)/\1:\/\2/g")
    printf "\033]7;file://%s\033\\" "$_win_path"
    else
    @@ -11,11 +12,5 @@ __vte_osc7 () {
    fi
    }

    case "$TERM" in
    xterm*|vte*)
    [ -n "$BASH_VERSION" ] && [ -n "$WT_SESSION" ] && PROMPT_COMMAND="__vte_osc7"
    [ -n "$ZSH_VERSION" ] && [ -n "$WT_SESSION" ] && precmd_functions+=(__vte_osc7)
    ;;
    esac

    true
    [ -n "$BASH_VERSION" ] && [ -n "$WT_SESSION" ] && PROMPT_COMMAND="__wt_osc7"
    [ -n "$ZSH_VERSION" ] && [ -n "$WT_SESSION" ] && precmd_functions+=(__wt_osc7)
  8. skyline75489 renamed this gist Sep 18, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. skyline75489 revised this gist Sep 18, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -13,8 +13,8 @@ __vte_osc7 () {

    case "$TERM" in
    xterm*|vte*)
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_osc7"
    [ -n "$ZSH_VERSION" ] && precmd_functions+=(__vte_osc7)
    [ -n "$BASH_VERSION" ] && [ -n "$WT_SESSION" ] && PROMPT_COMMAND="__vte_osc7"
    [ -n "$ZSH_VERSION" ] && [ -n "$WT_SESSION" ] && precmd_functions+=(__vte_osc7)
    ;;
    esac

  10. skyline75489 revised this gist Sep 18, 2020. 1 changed file with 4 additions and 10 deletions.
    14 changes: 4 additions & 10 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -11,17 +11,11 @@ __vte_osc7 () {
    fi
    }

    __vte_prompt_command() {
    local pwd='~'
    [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
    pwd="${pwd//[[:cntrl:]]}"
    printf "\033]0;\\\\wsl$\%s%s\033\\" "$DIST" "${pwd}"
    __vte_osc7
    }

    case "$TERM" in
    xterm*|vte*)
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_osc7"
    [ -n "$ZSH_VERSION" ] && precmd_functions+=(__vte_osc7)
    ;;
    esac
    esac

    true
  11. skyline75489 created this gist Sep 18, 2020.
    27 changes: 27 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    DIST="Ubuntu"

    __vte_osc7 () {
    # Windows Path
    if [[ "$(pwd)" =~ ^/mnt/* ]]; then
    _win_path=$(echo "$(pwd)" | sed -e "s/\/mnt\\/\([a-zA-Z]*\)\/\(.*\)/\1:\/\2/g")
    printf "\033]7;file://%s\033\\" "$_win_path"
    else
    # Linux Path
    printf "\033]7;file://\\\\\\\\wsl$\\%s%s\033\\" "$DIST" "$(pwd)"
    fi
    }

    __vte_prompt_command() {
    local pwd='~'
    [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
    pwd="${pwd//[[:cntrl:]]}"
    printf "\033]0;\\\\wsl$\%s%s\033\\" "$DIST" "${pwd}"
    __vte_osc7
    }

    case "$TERM" in
    xterm*|vte*)
    [ -n "$BASH_VERSION" ] && PROMPT_COMMAND="__vte_prompt_command"
    [ -n "$ZSH_VERSION" ] && precmd_functions+=(__vte_osc7)
    ;;
    esac